Reputation: 249
I have two tasks and they are 'styles' and 'clean-styles'. A watch task watches for any changes in .less files and triggers the styles task when it finds a change. This scenario works fine.
When there is a syntax error in .less, the error is shown on cmd line by gulp-plumber and rest of execution stops which is also correct.
Upon correcting the mistake in .less, watch resumes and triggers off styles task, but styles task just completes the dependent clean-styles task and nothing proceeds further.
I also want style task to execute. Please help.
gulp.task('styles', ['clean-styles'], function () {
config.log('Less -> CSS compilation in progress... [gulp-inject, gulp-less, autoprefixer]');
var partialLessfiles = gulp.src(
[
path.join(config.paths.styles, '**/*.less'),
path.join('!' + config.paths.styles, 'index.less')
],
{read: false}
).pipe(print());
return gulp.src([path.join(config.paths.styles, 'index.less')])
.pipe(inject(partialLessfiles, injectOptions))
.pipe(plumber())
.pipe(less())
.pipe(autoprefixer())
.pipe(gulp.dest(config.paths.temp));
});
gulp.task('clean-styles', function() {
config.log('Deleting all styles from .tmp in progress...');
var files = config.paths.temp + '**/*.css';
config.clean(files);
});
config.clean = function(path) {
util.log('Deleting ' + path);
del(path);
};
gulp.task('less-watcher', function() {
config.log('Watching for any changes in .less files... [watch]');
gulp.watch([config.paths.allless], ['styles']);
});
Upvotes: 0
Views: 63