Max SchmittMS
27th February 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:

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']);
Image of my head

About the author

Hi, I’m Max! I'm a fullstack JavaScript developer living in Berlin.

When I’m not working on one of my personal projects, writing blog posts or making YouTube videos, I help my clients bring their ideas to life as a freelance web developer.

If you need help on a project, feel free to contact me.

To stay updated with new blog posts, follow me on Twitter or subscribe to my RSS feed.