使用Watchify集成gulp-livereload

ben*_*e89 5 node.js browserify livereload gulp

我正在使用Substack的Watchify在Gulp监视任务中获得更好的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();
});
Run Code Online (Sandbox Code Playgroud)

试图找出如何将Live Reload合并到任务中,以便在Watchify完成它时触发它.知道怎么做吗?

Ove*_*ous 7

你是否尝试过使用gulp-livereload你的右后gulp.dest()

你应该能够简单地插入:

.pipe(livereload())
Run Code Online (Sandbox Code Playgroud)

这假定bundler.bundle()管道正确的数据类型.