我开始使用Gulp,我想创建一个任务,使用哈希重命名文件(js,css),然后将它们重新注入html。
实际上,我有两个功能可以满足我的要求,但是我无法弄清楚如何删除旧文件并仅保留新的js和css哈希文件。
有些可以给我提示吗? 这是我现在的代码:
obs:“ config”变量具有文件夹位置
gulp.task('prod:rev',['prod:revision'],function() {
var manifest = gulp.src(config.prod.manifest);
return gulp
.src(config.prod.header)
.pipe(plugin.revReplace({manifest: manifest}))
.pipe(gulp.dest('../'));
});
gulp.task('prod:revision',function(){
var revJs = gulp
.src(config.scripts.build+'*.js')
.pipe(plugin.rev())
.pipe(gulp.dest(config.scripts.build))
.pipe(plugin.rev.manifest({merge: true}))
.pipe(gulp.dest(config.prod.path));
var revCss = gulp
.src(config.styles.build+'*.css')
.pipe(plugin.rev())
.pipe(gulp.dest(config.styles.build))
.pipe(plugin.rev.manifest({merge: true}))
.pipe(gulp.dest(config.prod.path));
return merge(revJs,revCss);