I'm new to gulp and i'm trying to watch jade and less files and clean the build directory before moving the new files. Somehow the task works for the first time i change a file and then it doesn't keep watching. I have found many different solutions but none of them worked for me. Here are my watch tasks:
gulp.task('watch', function() {
gulp.watch(config.lessDir + '/**.less', ['css']);
gulp.watch(config.jadeDir + '/**.jade', ['jade']);
});
gulp.task('jade', function() {
del.sync(['build/**.html']);
return gulp.src(config.jadeDir + '/**.jade')
.pipe(jade({ pretty: true }))
.pipe(gulp.dest('./build'));
});
gulp.task('css', function() {
del.sync(['build/css/**.*']);
return gulp.src(config.lessDir + '/**.less')
.pipe(less())
.pipe(gulp.dest('./build/css'))
.pipe(minifyCSS())
.pipe(extReplace('.min.css'))
.pipe(gulp.dest('./build/css'));
});
With plumber i get the error "undefined is not a function".
Edit: Seems like del is not the problem but rather the pipelines handling the jade/less files.
delis this, thendel.syncdoes not accept a callback. Thecbwill probably never get called. Now this may confuse Gulp that, when the task function receives an argument, it expects this argument to be called to know that the task finished. Actually I do not know which takes precedence to determine task completion, the callback argument or the returned stream, but using both is at least confusing if not error prone.