我想知道是否有一种方法可以让通知显示gulp-sass错误消息。最好是控制台中显示的实际消息。
我的大嘴巴任务看起来像这样:
gulp.task 'styles',function(){ return gulp.src('src / scss / style.scss') .pipe(sass({style:'compressed',errLogToConsole:true})) .pipe(autoprefixer('last 2 version','safari 5','ie 8','ie 9','opera 12.1','ios 6','android 4'))。管道(gulp.dest('')) .pipe(livereload(server)).pipe(notify({message:'Styles task complete'})); });我想通知某种错误回调。
任何帮助表示赞赏。
解决方案在与我自己挣扎后,我发现这个工作: <$ ($ s $ / $ s $ / $ s $ / $ s $) .pipe(sass('src / scss / style.scss' { 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'))); });
您需要使用 onError 选项,gulp-sass提供。
希望有帮助!
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 like this:
gulp.task('styles', function() { return gulp.src('src/scss/style.scss') .pipe(sass({ style: 'compressed', errLogToConsole: true })) .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' })); });I'd like to pipe the notify to some kind of error callback.
Any help appreciated.
解决方案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!
更多推荐
与通知一起的咕嘟声错误
发布评论