与Watchify集成gulp-livereload

我正在使用Substack的Watchify更好的Browserify构build,在一个Gulp监视任务中,像这样:

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完成它时触发它。 任何想法我会如何做到这一点?

你尝试使用gulp-livereload后,你的gulp.dest()

你应该能够简单地插入这个:

 .pipe(livereload()) 

这假设bundler.bundle()pipe道正确的数据types。

Interesting Posts