gulp Sass和errLogToConsole:true仍然停止我的其他监视任务 [英] Gulp Sass with errLogToConsole: true still stopping my other watch tasks
问题描述
gulp.task('watch',function(){
gulp.watch(sassDir +'/*.scss',['sass']);
gulp.watch(cssDir +'/*.css',['css']);
gulp.watch(jsDir +'/*.js',['js']);
})
我现在的问题是,当Sass抛出错误时,所有监视任务都会停止。
然后我添加了 .pipe(sass({errLogToConsole:true}))
- 这似乎让我的sass watch任务仍然存在,即使出现错误,其他手表任务似乎无法运行。
我如何让所有的手表任务保持活动状态,以便我的sass文件中的错误不会停止一切从被编译?
我的设置:
gulp.task('sass',function(){
gulp.src(sassDir +'/**/*.scss')
.pipe(sass({errLogToConsole:true}))
.pipe(gulp.dest(sassTargetDir));
});
gulp.task('css',function(){
gulp.src(cssDir +'/**/*.css')
.pipe(autoprefix({
browsers:['last 40 versions'],
cascade:false
}))
.pipe(gulp.dest(cssTargetDir))
.pipe(minify ())
.pipe(rename({suffix:'.min'}))
.pipe(gulp.dest(cssTargetDir));
});
gulp.task('js',function(){
gulp.src(jsDir +'/**/*.js')
.pipe(gulp.dest (jsTargetDir))
.pipe(uglify())
.pipe(rename({suffix:'.min'}))
.pipe(gulp.dest(jsTargetDir))
});
gulp.task('watch',function(){
gulp.watch(sassDir +'/*.scss',['sass']);
gulp。 watch(cssDir +'/*.css',['css']);
gulp.watch(jsDir +'/*.js',['js']);
})
gulp.task('default',['sass','css','js','watch']);
errLogToConsole已弃用(或不起作用) Gulp 2.0+。尝试使用它来代替 .pipe(sass({errLogToConsole:true}))
。
.pipe(sass()。on('error',sass.logError))
我使用watch命令,错误不会阻止Gulp。
我从Gulp示例代码和几个最新的Gulp指南中获得了这个信息。今后检查。 https://github.com/dlmanning/gulp-sass
I currently have 3 watch tasks as so:
gulp.task('watch', function(){
gulp.watch(sassDir + '/*.scss', ['sass']);
gulp.watch(cssDir + '/*.css', ['css']);
gulp.watch(jsDir + '/*.js', ['js']);
})
My issue right now is that when Sass throws an error all watch tasks stops.
I then added .pipe(sass({errLogToConsole: true}))
- which seems to keep my sass watch task alive even with an error, however the two other watch tasks doesnt seem to run.
How do I keep all of my watch tasks a live, so that an error in my sass file doesn't stop everything from being compiled?
My setup:
gulp.task('sass', function () {
gulp.src(sassDir + '/**/*.scss')
.pipe(sass({errLogToConsole: true}))
.pipe(gulp.dest(sassTargetDir));
});
gulp.task('css', function() {
gulp.src(cssDir + '/**/*.css')
.pipe(autoprefix({
browsers: ['last 40 versions'],
cascade: false
}))
.pipe(gulp.dest(cssTargetDir))
.pipe(minify())
.pipe(rename({suffix: '.min'}))
.pipe(gulp.dest(cssTargetDir));
});
gulp.task('js', function() {
gulp.src(jsDir + '/**/*.js')
.pipe(gulp.dest(jsTargetDir))
.pipe(uglify())
.pipe(rename({suffix: '.min'}))
.pipe(gulp.dest(jsTargetDir))
});
gulp.task('watch', function(){
gulp.watch(sassDir + '/*.scss', ['sass']);
gulp.watch(cssDir + '/*.css', ['css']);
gulp.watch(jsDir + '/*.js', ['js']);
})
gulp.task('default', ['sass','css','js','watch']);
errLogToConsole is deprecated (or doesn't work) with Gulp 2.0+. Try using this in place of .pipe(sass({errLogToConsole: true}))
.
.pipe(sass().on('error', sass.logError))
I use that with the watch command and the errors don't stop Gulp.
I got this from the Gulp sample code and a few more up-to-date Gulp guides. Check here in the future. https://github.com/dlmanning/gulp-sass
这篇关于gulp Sass和errLogToConsole:true仍然停止我的其他监视任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!