0

I’ve noticed that if I gulp.watch() a directory with ~400 Markdown files, my Gulp task takes a long time to initialize (~19s on my machine). If I remove this specific .watch() call, my task initialization time shrinks to less than 100ms.

gulp.task('my-task', function () {

    // these calls are very quick (< 100ms) 
    gulp.watch('source/styl/*.styl', ['build-css']);
    gulp.watch('source/js/index/*.js', ['build-js']);
    gulp.watch(['app.js', 'modules/*.js', 'routes/*.js', 'views/*.jade'], [server.run]);
    gulp.watch(['source/js/index/*.js', 'app.js', 'modules/*.js', 'routes/*.js', 'gulpfile.js'], ['lint-js']);
    gulp.watch('source/img/**/*', ['compress-images']);

    // this call takes ~19s to complete
    gulp.watch('source/md/releases/*.md', ['build-releases']);
});

Is there anything I can to to resolve this performance issue, or is watching directories with hundreds of files not feasible in Gulp?


Update: I have switched to a callback function:

gulp.watch('source/md/releases/*.md', function (e) {
    // console.log(e.path);
});

and I’m still experiencing the same performance issue.

Šime Vidas
  • 182,163
  • 62
  • 281
  • 385

0 Answers0