Here's my gulpfile.js
contents:
const fs = require( 'fs' );
const gulp = require( 'gulp' );
exports.watch = gulp.series( watch );
function watch() {
const file = 'src/style.scss';
console.log( fs.readFileSync( file ).length );
gulp.watch( file, gulp.series( sass ) );
}
function sass( done ) {
console.log( 'Success!' );
done();
}
When I run gulp watch
, it starts watching but changes made to src/style.scss
don't reflect. I can see length of the file content on console, but can never see the Success! message.
Before posting it here, I've gone through the Gulp4 documentation over and over again, checked a lot of solutions regarding Gulp Watch including this one, but won't be able to figure out the exact issue.
Your help on this is highly appreciated. Thanks in advance.
Update
The following code is working as expected on Gulp 3.9.1
const gulp = require( 'gulp' );
gulp.task( 'default', () => {
gulp.watch( 'src/style.scss', [ 'sass' ] );
});
gulp.task( 'sass', () => {
console.log( 'Success!' );
});
But the following one is not working on Gulp 4.0.0
const gulp = require( 'gulp' );
exports.default = gulp.series( watch );
function watch( done ) {
gulp.watch( 'src/style.scss', gulp.series( sass ) );
done();
}
function sass( done ) {
console.log( 'Success!' );
done();
}
Environment:
- OS: CentOS Linux release 7.6.1810 (Core)
- NPM: 6.4.1
- Node: v10.15.1
Am I doing any silly mistake, or it is a BUG?