gulp-plumber: Not working with gulp-sass

My terminal still returns an error and breaks my task when there’s an error in my Sass. This is what my task looks like:

gulp.task('sass', function() {
  return gulp.src(['./src/scss/*.scss', './src/scss/**/*.scss'])
    .pipe(plumber())
    .pipe(sass({
      includePaths : [
        './lib/basscss/scss',
        './lib/fluidbox/css'
      ],
      outputStyle: 'expanded'
    }))
    .pipe(prefix({
      browsers: ['last 2 versions'],
      cascade: false
    }))
    .pipe(minifyCSS())
    .pipe(gulp.dest('./_site/public/css'))
    .pipe(gzip())
    .pipe(gulp.dest('./_site/public/css'))
    .pipe(reload({stream: true}))
});

Any idea why it keeps breaking? Any help is appreciated. Thanks in advance!

About this issue

  • Original URL
  • State: open
  • Created 9 years ago
  • Reactions: 3
  • Comments: 17 (1 by maintainers)

Commits related to this issue

Most upvoted comments

@holic You’re right! @realph keep code but remove return. gulp.task(‘sass’, function() { gulp.src(…) .pipe(plumber()) .pipe(sass({…})); });

@joshtoo I got it to work this way:

gulp.task('sass', function() {
  return gulp.src('scss/style.scss')
    .pipe(plumber())
    .pipe(sass.sync({ // Have to use sass.sync - See Issue (https://github.com/dlmanning/gulp-sass/issues/90)
      outputStyle: 'compressed',
      errLogToConsole: true
    }))
    .pipe(autoprefixer({
      browsers: ['last 2 versions', 'ie >= 9']
    }))
    .pipe(gulp.dest('./'));
});

would that do the trick?

@TheAggressive

var $ = require('gulp-load-plugins')({lazy: true}); // John Papa tip for shortening the require list

gulp.task('sass', ['clean-sass'], function() {
    log('SASS Compilation ==> CSS3');

    return gulp
        .src(conf.sass)
        .pipe($.plumber())
        .pipe($.sass())
        .on('error', $.sass.logError)
        .pipe($.autoprefixer({browsers: ['last 2 version', '> 5%']}))
        .pipe(gulp.dest(conf.tempDir));

});

@realph Try calling gulp-sass with sass.sync instead of sass.

See https://github.com/dlmanning/gulp-sass/wiki/Common-Issues-and-Their-Fixes#gulp-watch-stops-working-on-an-error for an explanation.