Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Integrate gulp-livereload with Watchify

I'm using Substack's Watchify for better Browserify builds, within a Gulp watch task, like so:

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();
});

Trying to figure out how I can incorporate Live Reload into the task, so it triggers when Watchify has done it's thing. Any idea how I would do this?

like image 326
benhowdle89 Avatar asked Feb 25 '14 21:02

benhowdle89


1 Answers

Have you tried using gulp-livereload right after your gulp.dest()?

You should be able simply insert this:

.pipe(livereload())

This assumes that bundler.bundle() pipes the correct data types.

like image 63
OverZealous Avatar answered Sep 19 '22 12:09

OverZealous