如何将 gulp-rev 与 file.revHash 一起使用?
How to use gulp-rev with file.revHash?
来自 gulp-rev @ link : https://github.com/sindresorhus/gulp-rev
我写了一个简单的任务
gulp.task('build-app', function () {
return gulp
.src([gulpConfig.clientApp + '*.js'])
.pipe($.rev())
// i want to get the updated hash, which I will use to replace the string in some place
}
知道如何实现吗?
您可以使用gulp-filenames to store the new/hashed filename. I haven't done this with gulp-rev but I have with gulp-freeze
gulp.task('css', function () {
return gulp.src('./js/**/*.js')
.pipe(freeze())
.pipe(filenames('some-string'))
.pipe(gulp.dest('./dist'));
});
然后在另一个任务中,您可以通过以下方式获取散列文件名:
filenames.get('some-string');
来自 gulp-rev @ link : https://github.com/sindresorhus/gulp-rev 我写了一个简单的任务
gulp.task('build-app', function () {
return gulp
.src([gulpConfig.clientApp + '*.js'])
.pipe($.rev())
// i want to get the updated hash, which I will use to replace the string in some place
}
知道如何实现吗?
您可以使用gulp-filenames to store the new/hashed filename. I haven't done this with gulp-rev but I have with gulp-freeze
gulp.task('css', function () {
return gulp.src('./js/**/*.js')
.pipe(freeze())
.pipe(filenames('some-string'))
.pipe(gulp.dest('./dist'));
});
然后在另一个任务中,您可以通过以下方式获取散列文件名:
filenames.get('some-string');