Max Schmitt

February 27 2014

gulp-watch and watching new files

Gulp.js is an awesome tool for running build tasks. The watch-plugin is really easy to use and works great.

However: by default, watch will not consider any new files that you add while watch is already running. To fix this, you can set the options.glob-parameter:

JS

gulp
.src('src/js/**/*.js')
.pipe(watch({ glob: 'src/js/**/*.js' }, function() {
gulp.start('browserify');
}));

With this configuration, gulp will watch all files that match src/js/**/*.js and automatically add any new files with that pattern to watch.

Update:

gulp now includes watch functionality by default, it's easier to setup, but it doesn't pickup when new files are added:

gulp.watch('src/js/**/*.js', ['browserify']);