Merge pull request #292 from L422Y/patch-1 - Thx @L422Y !

Add basic error handling for `gulp-plumber`
This commit is contained in:
Holger 2017-05-16 09:03:31 +02:00 committed by GitHub
commit 6103e6d5e7
1 changed files with 30 additions and 5 deletions

View File

@ -49,7 +49,12 @@ var cleanCSS = require('gulp-clean-css');
// Prepare the min.css for production (with 2 pipes to be sure that "theme.css" == "theme.min.css") // Prepare the min.css for production (with 2 pipes to be sure that "theme.css" == "theme.min.css")
gulp.task('scss-for-prod', function() { gulp.task('scss-for-prod', function() {
var source = gulp.src('./sass/*.scss') var source = gulp.src('./sass/*.scss')
.pipe(plumber()) .pipe(plumber({
errorHandler: function (err) {
console.log(err);
this.emit('end');
}
}))
.pipe(sourcemaps.init({loadMaps: true})) .pipe(sourcemaps.init({loadMaps: true}))
.pipe(sass()); .pipe(sass());
@ -73,7 +78,12 @@ gulp.task('scss-for-prod', function() {
// Prepare the child-theme.css for the development environment // Prepare the child-theme.css for the development environment
gulp.task('scss-for-dev', function() { gulp.task('scss-for-dev', function() {
gulp.src('./sass/*.scss') gulp.src('./sass/*.scss')
.pipe(plumber()) .pipe(plumber({
errorHandler: function (err) {
console.log(err);
this.emit('end');
}
}))
.pipe(sourcemaps.init({loadMaps: true})) .pipe(sourcemaps.init({loadMaps: true}))
.pipe(sass()) .pipe(sass())
.pipe(sourcemaps.write(undefined, { sourceRoot: null })) .pipe(sourcemaps.write(undefined, { sourceRoot: null }))
@ -90,7 +100,12 @@ gulp.task('watch-scss', ['browser-sync'], function () {
// Compiles SCSS files in CSS // Compiles SCSS files in CSS
gulp.task('sass', ['minify-css'], function () { gulp.task('sass', ['minify-css'], function () {
var stream = gulp.src('./sass/*.scss') var stream = gulp.src('./sass/*.scss')
.pipe(plumber()) .pipe(plumber({
errorHandler: function (err) {
console.log(err);
this.emit('end');
}
}))
.pipe(sass()) .pipe(sass())
.pipe(gulp.dest('./css')) .pipe(gulp.dest('./css'))
.pipe(rename('custom-editor-style.css')) .pipe(rename('custom-editor-style.css'))
@ -126,7 +141,12 @@ gulp.task('imagemin', function(){
gulp.task('cssnano', function(){ gulp.task('cssnano', function(){
return gulp.src('./css/theme.css') return gulp.src('./css/theme.css')
.pipe(sourcemaps.init({loadMaps: true})) .pipe(sourcemaps.init({loadMaps: true}))
.pipe(plumber()) .pipe(plumber({
errorHandler: function (err) {
console.log(err);
this.emit('end');
}
}))
.pipe(rename({suffix: '.min'})) .pipe(rename({suffix: '.min'}))
.pipe(cssnano({discardComments: {removeAll: true}})) .pipe(cssnano({discardComments: {removeAll: true}}))
.pipe(sourcemaps.write('./')) .pipe(sourcemaps.write('./'))
@ -136,7 +156,12 @@ gulp.task('cssnano', function(){
gulp.task('minify-css', function() { gulp.task('minify-css', function() {
return gulp.src('./css/theme.css') return gulp.src('./css/theme.css')
.pipe(cleanCSS({compatibility: 'ie8'})) .pipe(cleanCSS({compatibility: 'ie8'}))
.pipe(plumber()) .pipe(plumber({
errorHandler: function (err) {
console.log(err);
this.emit('end');
}
}))
.pipe(rename({suffix: '.min'})) .pipe(rename({suffix: '.min'}))
.pipe(gulp.dest('./css/')); .pipe(gulp.dest('./css/'));
}); });