For a while now, I've been experimenting with watchify and encountering a saving issue.
It appears that every time I make a change, I have to save twice for the modifications to reflect in the output.
If I add new code to any JavaScript file, the changes only take effect after running the task two times.
Snippet of my mainScripts-task code
var customOpts = {
entries: ['./app/app.js'],
debug: true
};
var opts = assign({}, watchify.args, customOpts);
var b = watchify(browserify(opts));
gulp.task('mainScripts', bundle);
b.on('update', bundle);
b.on('log', gutil.log);
function bundle() {
console.log('bundle');
return b.bundle()
.on('error', gutil.log.bind(gutil, 'Browserify Error'))
.pipe(source('main.js'))
.pipe(buffer())
.pipe(gulpif(!condition, sourcemaps.init({
loadMaps: true
})))
.pipe(gulpif(!condition, sourcemaps.write('./')))
.pipe(gulp.dest('./dist/js/'))
.pipe(gulpif(isLocal(), connect.reload()));
}
The "watch"-task implementation
gulp.task('watch', function() {
gulp.watch('app/**/*.js', ['mainScripts']);
});