I am trying to get watchify working with Gulp but it seems that the 'update' event is never fired.
Here's my gulpfile.js:
"use strict";
var gulp = require('gulp');
var browserify = require('browserify');
var source = require("vinyl-source-stream");
var watchify = require('watchify');
var bundler = watchify(browserify({entries: ['./client/app/app.js'], cache: {}, packageCache: {}, fullPaths: true}));
gulp.task('js', bundle);
function bundle() {
console.log('bundle');
return bundler.bundle()
.pipe(source('bundle.js'))
.pipe(gulp.dest('./dist'));
}
// this is never fired!
bundler.on('update', bundle);
However, when I explicitly watch the files without watchify it works:
"use strict";
var gulp = require('gulp');
var browserify = require('browserify');
var source = require("vinyl-source-stream");
var watchify = require('watchify');
function bundle() {
console.log('bundle');
return browserify('./client/app/app.js')
.bundle()
.pipe(source('bundle.js'))
.pipe(gulp.dest('./dist/'));
}
gulp.task('browserify', bundle);
gulp.task('js', function() {
bundle();
gulp.watch(['client/**/*.js'], ['browserify']);
});
I've tried numerous examples but with watchify the bundle never updates.
I'm running Gulp inside a Vagrant VM, host is OSX Yosemite, guest is Ubuntu 14.04.
Any help is greatly appreciated!