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

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

    the best solution I have tried; https://github.com/gulpjs/gulp/blob/master/docs/recipes/combining-streams-to-handle-errors.md

    var combiner = require('stream-combiner2');
    gulp.task('multi:less', function(done) {
        var combined = combiner.obj([
            gulp.src(srcs),
            less(),
            autoprefixer({
                browsers: ['last 6 versions'],
                cascade: false
            }),
            isDev ? null : cleanCss(),
            gulp.dest(targetDir + 'css/multi/'),
        ].filter(v => v));
    
        // any errors in the above streams will get caught
        // by this listener, instead of being thrown:
        combined.on('error', console.error.bind(console));
        combined.on('end', () => {}); //done have been call when return combined;
        return combined;
    
    }
    

提交回复
热议问题