-
Notifications
You must be signed in to change notification settings - Fork 64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
A way to configure gulp-postcss not to fail a build on css syntax error #51
Comments
This might be helpful for you - https://www.npmjs.com/package/gulp-plumber |
@11bit @matchabros It's gulp issue. Where it catches only last pipe error. I decide it with gulp.task('css', function (done) {
return gulp.src(...)
// not last pipe
.pipe(postcss(...))
.on('error', done)
// Last pipe error will be caught
.pipe(gulp.dest(...))
}) |
@matchabros @TrySound Thanks guys. Anyway gulp 4 is going to bring a new error handling. I hope it won't need to use plumber of custom error handling no more. |
I've tried using gulp.task('css', function () {
var processors = [
atImport,
simplevars,
map(opts),
nestedcss,
colorFunction,
ms,
lost,
autoprefixer({browsers: ['last 1 version', 'ie 10']})
];
return gulp.src('./css/main.css')
.pipe( plumber() )
.pipe( sourcemaps.init() )
.pipe( postcss(processors) )
.pipe( rucksack() )
// .pipe( nano() )
.pipe( sourcemaps.write('.') )
.pipe( gulp.dest('build/css/') )
.pipe( browserSync.stream({match: "**/*.css"}) );
// .pipe( browserSync.reload({stream: true, match: "**/*.css"}) );
}); |
@lmartins plumber is ugly hack. You can see here in case how I organize my build process. |
Thanks @TrySound, will study your example :) |
@lmartins your issue might be coming from not using an error handler with gulp-plumber. I just had a look myself and got rid of my errorHandler inside of Here's the errorHandler I use in my build. function errorAlert(err) {
$.notify.onError({
title: 'Gulp Error',
message: 'An error occured, check your terminal',
sound: 'Basso'
})(err);
gutil.log(gutil.colors.red(err.toString()));
this.emit('end');
} |
@matchabros The problem is that for CI this code won't exit with error code. |
@TrySound Pardon me if my lack of knowledge will come out right now, but could you elaborate on what you meant ? |
@matchabros If you use something like travis ci, |
@TrySound I see, thanks for taking a moment and explaining. |
Is there a way to configure PostCSS plugin to just log the error and not fail a build when it encounters a css syntax error? It may be useful in some live-reloading workflows. For instance when I use gulp with browser-sync's watch plugin that lints code on every change the failed build also fails watching process so I have to restart it every time.
As a possible solution gulp-poctcss may have a switch to handle all postcss errors, log them to console and proceed:
The text was updated successfully, but these errors were encountered: