Gulp.js stops compiling LESS when watched after there has been an error in the LESS files

前端 未结 4 1482
孤城傲影
孤城傲影 2021-02-08 02:06

I\'m having a problem with gulp. I run gulp-watch along with gulp-less and gulp-clean. Everything is running perfectly.

4条回答
  •  北海茫月
    2021-02-08 02:36

    It works now! Here is my final, and working, gulp-less task:

    gulp.task('less', function() {
        return gulp.src(['src/main/webapp/styles/main.less'], {base: 'src/main/webapp/styles/'})
        .pipe(less().on('error', function(err){
            gutil.log(err);
            this.emit('end');
        }))
        .pipe(gulp.dest('src/main/webapp/styles/build'))
    });
    

    The problem was that, when there was an error in the LESS the task still went on and built the destination file. On top of that I placed the error logging function and the emit('end') as a callback to gulp.dest.

    Now, when the callback of less() is the error log and emit('end') everything works perfectly.

提交回复
热议问题