Search code examples
node.jsgulp

Gulp run watch task once at start


When starting to watch my files, the file system might have changed, when the watch was not on-line. How can I make my watch run the task once at start, after typing in the command gulp dev?

gulp.task('dev', function () {
    gulp.watch('src/**/*', ['scss','inject']);
}); 

Solution

  • Add this to your gulpfile.js:

    gulp.task('dev', ['scss', 'inject', 'watch']);
    

    This way those tasks run first, and then the watch task starts so any changes to the files are accounted for prior to the Watch task starting.