Closed yanneves closed 6 years ago
This project was developed for v2 version of gulp
, I think, and worked with v3. v4 planned ship this feature internally.
Thanks for looking into this @floatdrop.
I've opted to use watch-spawn to handle watch tasks as a wrapper around Gulp, until this can be remedied.
Plumber works fine with gulp4
let gulp = require('gulp'),
sass = require('gulp-sass'),
plumber = require('gulp-plumber'),
prefixer = require('gulp-autoprefixer'),
csso = require('gulp-csso'),
config = require('../../config');
gulp.task('scss:build', (done) => {
return new Promise((resolve, reject) => {
gulp.src(config.src + 'scss/**/*.scss')
.pipe(plumber())
.pipe(sass({
errLogToConsole: false,
outputStyle: "expanded",
sourceMap: false
}))
.pipe(prefixer(config.prefixer))
.pipe(csso())
.pipe(plumber.stop())
.pipe(gulp.dest(config.dist + "css"))
.pipe(global.livereload.reload({stream: true}))
.on('end', resolve)
.on('error', reject);
done();
})
});
gulp.task('scss:watch', () => {
global.watch = true;
gulp.watch(config.src + 'scss/**/*.scss', gulp.series('scss:build'))
.on('all', (event, filepath) => {
// Reserved for emmity
});
});
global.livereload
- instance of browsersync defined elsewhere.
Even with notifications:
//...
let color = require("colors");
let onError = function(error) {
process.stderr.write(
"\007\n" +
color.red.bold.inverse(error.name) +
color.white.bold(" in " + error.plugin) +
color.white.bold("\n\nMessage\n") +
color.red.bold(error.message) + "\n"
)
this.emit('end');
}
// ...
.pipe(plumber({errorHandler: onError}))
// ...
gulp-plumber is working for me with Gulp 4.0.0.
I’m using it to log errors to the console and with node-notifier (showing system notifications), so that watch tasks don’t fail on the first syntax error (e.g. when writing Sass code). Errors are indeed logged and the watch tasks keeps running.
Lots of changes in both codebases since I raised this issue. Will close as I think this is now resolved - thanks!
I'm lead to believe the following works in earlier versions of Gulp. However, in Gulp v4 using the built-in
gulp.watch
method, this successfully swallows errors the first time a change is detected but prevents future changes being detected.Is this project intended to support Gulp v4? Using Node v7.1.0.