automatix
automatix

Reputation: 14512

How to get Gulp v4 watch observe file changes?

Here is a very minimalistic example gulpfile.js:

var gulp = require('gulp');
function foo(done) {
    console.log('change');
    done();
}
function watchFiles() {
    console.log('starting watching...');
    gulp.watch('./gulpfile.js', gulp.series(foo));
};
gulp.task('watch-files', gulp.series(watchFiles));

A message "change" should be displayed on the console every time, when the gulpfile.js itself gets edited. But it doesn't work. I get the initial message "starting watching..." and the Gulp info about starting the task displayed.

$ gulp watch-files
[[[00:07:48] Using gulpfile /var/www/.../my-app/gulpfile.js
[00:07:48] Starting 'watch-files'...
[00:07:48] Starting 'watchFiles'...
starting watching...

But changes on the defined file to be observed (the gulpfile.js) are ignored, so no further messages are being displayed.

What causes the issue and how to fix it and get the watching working?

Upvotes: 0

Views: 371

Answers (0)

Related Questions