5
我使用亚组的Watchify更好Browserify建立,一饮而尽手表任务中,像这样:整合一饮而尽,livereload与Watchify
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();
});
试图找出我如何可以将现场重新放回任务,所以它在Watchify完成它的事情时触发。任何想法我会如何做到这一点?
[vinyl-source-stream](https://github.com/hughsk/vinyl-source-stream)('.pipe(source('bundle.js'))'在他的代码中)将文本流从'bundler.bundle()'管道输出,并使其成为gulp使用的乙烯文件流,替换'gulp.src()'。因此,其他的一些插件可以在那之后传输。 – DSKrepps
啊,谢谢,我没有看到那一行。很高兴知道! – OverZealous
另请注意,如果你使用gulp-connect,你可以'.pipe(connect.reload())' –