Gulp Sass with errLogToConsole: true still stops my other tasks
I currently have 3 monitoring tasks:
gulp.task('watch', function(){
gulp.watch(sassDir + '/*.scss', ['sass']);
gulp.watch(cssDir + '/*.css', ['css']);
gulp.watch(jsDir + '/*.js', ['js']);
})
My problem right now is that when Sass throws an error, all view tasks stop. Then I added .pipe(sass({errLogToConsole: true}))
- which seems to keep my sass watch task pending even with an error, however the other two watch tasks don't seem to work.
How do I keep all my viewing tasks live so that a bug in my sass file doesn't prevent everything from compiling?
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']);
source to share
errLogToConsole is deprecated (or doesn't work) since Gulp 2.0+. Try using this instead .pipe(sass({errLogToConsole: true}))
.
.pipe(sass().on('error', sass.logError))
I use this with watch command and the errors are not stopped by Gulp.
I got this from the Gulp example code and a few more modern Gulp tutorials. Check here in the future. https://github.com/dlmanning/gulp-sass
source to share