我在 Gulp 监视任务中使用 Substack 的 Watchify 来构建更好的 Browserify,如下所示:
var gulp = require('gulp');
var source = require('vinyl-source-stream');
var watchify = require('watchify');
var hbsfy = require("hbsfy").configure({
extensions: ["html"]
});
gulp.task('watch', function() {
var bundler = watchify('./public/js/app.js');
bundler.transform(hbsfy);
bundler.on('update', rebundle);
function rebundle() {
return bundler.bundle()
.pipe(source('bundle.js'))
.pipe(gulp.dest('./public/dist/js/'));
}
return rebundle();
});
试图弄清楚如何将 Live Reload 合并到任务中,以便在 Watchify 完成时触发它。知道我会怎么做吗?