floatdrop / gulp-plumber

Fixing Node pipes
MIT License
806 stars 32 forks source link

Stops after "Error in plugin 'gulp-postcss' " #42

Open nerijusgood opened 8 years ago

nerijusgood commented 8 years ago

Gulp task:

gulp.task('css', function () {
    var processors = [
        cssnested,
        cssimport,
        csssimplevars,
        cssnext(),
        cssnano
    ];
    return gulp.src('./src/css/main.css')
        .pipe(plumber())
        .pipe(sourcemaps.init())
            .pipe(postcss(processors))
        .pipe(sourcemaps.write('.'))
        .pipe(gulp.dest('./css'))
        .pipe(reload({stream:true}));
});

gulp.task('watch', function() {
    gulp.watch(paths.css, ['css']);
});

Whenever there is an error, like importing file that does not exist (wrong path), I get this error which stops gulp:

[15:31:29] Starting 'css'...
[15:31:29] Plumber found unhandled error:
 Error in plugin 'gulp-postcss'
Message:
    /Users/Nerijus/Sites/Personal/solofront/user/themes/solofront-theme/src/css/main.css:5:1: Failed to find 'base/header' from /Users/Nerijus/Sites/Personal/solofront/user/themes/solofront-theme
    in [
        /Users/Nerijus/Sites/Personal/solofront/user/themes/solofront-theme/src/css
    ]
Details:
    originalMessage: Failed to find 'base/header' from /Users/Nerijus/Sites/Personal/solofront/user/themes/solofront-theme
    in [
        /Users/Nerijus/Sites/Personal/solofront/user/themes/solofront-theme/src/css
    ]
    fileName: /Users/Nerijus/Sites/Personal/solofront/user/themes/solofront-theme/src/css/main.css
    lineNumber: 5
    columnNumber: 1

Really annoying causing me to restart my tasks every time css error is made. Am I doing something wrong?

msfragala commented 8 years ago

I'm having a similar problem using gulp-postcss, gulp-plumber, and gulp-watch together — task shown below. When the task encounters a CSS error, the task remains open and the error is logged per the warn error handler passed in, so all is good so far. But the build files aren't updated with any changes made to the source files, like fixing the error.

gulp-watch does still continue to log that changes were detected in the source files; they just don't get processed anymore unless I restart the task over again.

gulp.task('styles', function() {
  gulp.src($.css.globs)
    .pipe(watch($.css.watch, {name: 'styles', verbose: true}))
    .pipe(plumber(warn))
    .pipe(postcss(parts))
    .pipe(gulp.dest($.css.dest));
});
ambethia commented 8 years ago

Has anyone found a solution/workaround for this yet?

mgol commented 8 years ago

Might be related: https://github.com/floatdrop/gulp-plumber/issues/30#issuecomment-191682090

armandabric commented 7 years ago

I have the same issue.

marko-g-stojkovic commented 6 years ago

I have this problem, but nobody resolved it as I see...

alkorlos commented 3 years ago

Bad fix: Will work with gulp-notify https://www.npmjs.com/package/gulp-notify import notify from 'gulp-notify'; and Instead .pipe(plumber()) insert .pipe(plumber({ errorHandler: notify.onError('Error: <%= error.message %>') }))

I don't know why it works, I found it when I wanted to delete gulp-notify, he has his own problems (with notifications).

ronilaukkarinen commented 3 years ago

Just notice the same. Solutions?