Gulp-sass error with notify

前端 未结 5 2066
粉色の甜心
粉色の甜心 2020-12-28 20:12

I wondered if there is a way to have notify display a message on gulp-sass error. preferably the actual message that is displayed in the console.

my gulp task looks

5条回答
  •  长情又很酷
    2020-12-28 21:15

    After struggling with this myself I found that this worked:

    gulp.task('styles', function() {
      return gulp.src('src/scss/style.scss')
        .pipe(sass({
            style: 'compressed',
            errLogToConsole: false,
            onError: function(err) {
                return notify().write(err);
            }
        }))
        .pipe(autoprefixer('last 2 version', 'safari 5', 'ie 8', 'ie 9', 'opera 12.1', 'ios 6', 'android 4'))
        .pipe(gulp.dest(''))
        .pipe(livereload(server))
        .pipe(notify({ message: 'Styles task complete' }));
    });
    

    You need to catch the error using the onError option that gulp-sass provides.

    Hope that helps!

提交回复
热议问题