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

前端 未结 4 1560
孤城傲影
孤城傲影 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:38

    I have just set this up for my own personal project. According to the Gulp docs, you can just use gulp.watch:

    gulp.task('watch', function() {
        gulp.watch('src/main/webapp/styles/**/*.{less, css}', ['less'])
            .on('error', gutil.log);
    });
    

    EDIT: If this doesn't help, change your less task to:

    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'))
        .on('error', gutil.log);
    });
    

    Adapted from this comment.

提交回复
热议问题