刚从 Gulp 开始 - 这太棒了。这可行,但 rev.manifest 会自行写入,并且其中没有“样式”和“脚本”。一定会有更好的办法。正确的?:-)
gulp.task('script', function() {
var scripts = gulp.src('source-js/main.js')
.pipe(uglify())
.pipe(rev())
.pipe(gulp.dest());
var manifest = gulp.src('./rev-manifest.json');
return es.merge(scripts, manifest)
.pipe(rev.manifest())
.pipe(gulp.dest('.'))
});
gulp.task('style', function() {
var styles = gulp.src('source-less/style.less')
.pipe(less({compress: true}))
.pipe(rev())
.pipe(gulp.dest());
var manifest = gulp.src('./rev-manifest.json');
return es.merge(styles, manifest)
.pipe(rev.manifest())
.pipe(gulp.dest('.'))
});
gulp.task('watch', function () {
gulp.watch('source-less/**/*.less', ['style']);
gulp.watch('source-js/**.js', ['script']);
});
编辑:尝试使用 es 仍然是编写清单的情人:
gulp.task('script', function() {
var scripts = gulp.src('source-js/main.js')
.pipe(uglify())
.pipe(rev())
.pipe(gulp.dest('assets/js'));
var manifest = gulp.src('./rev-manifest.json');
return es.merge(scripts, manifest)
.pipe(rev.manifest())
.pipe(gulp.dest('.'))
});
gulp.task('style', function() {
var styles = gulp.src('source-less/style.less')
.pipe(less({compress: true}))
.pipe(rev())
.pipe(gulp.dest('assets/css'));
var manifest = gulp.src('./rev-manifest.json');
return es.merge(styles, manifest)
.pipe(rev.manifest())
.pipe(gulp.dest('.'))
});