Snippets

Duane Blake System notifcation in Gulp using Notify and Plumber

Created by Duane Blake
var gulp            = require('gulp'),
    sass            = require('gulp-sass'),   
    plumber         = require('gulp-plumber'),
    notify          = require("gulp-notify");

var onError = function (err) {
    notify({
        title: 'Gulp Task Error',
        message: 'Check the console.'
    }).write(err);

    console.log(err.toString());

    this.emit('end');
}

gulp.task('sass', function (){
    return gulp.src('./scss/**/*.scss')
    .pipe(plumber({ errorHandle: onError }))
    .pipe(sass())
    .on('error', onError)
    .pipe(gulp.dest('./css'))
    .pipe(notify({
        title   : 'Gulp Task Complete',
        message : 'Styles have been compiled'
    }));
}); 

gulp.task('watch', function() {
    gulp.watch(['./scss/**/*.scss'], ['sass']);
});
1
2
3
4
5
6
7
8
{
  "devDependencies": {
    "gulp": "^3.9.1",
    "gulp-notify": "^2.2.0",
    "gulp-plumber": "^1.1.0",
    "gulp-sass": "^2.3.2"
  }
}

Comments (0)