Skip to content

Instantly share code, notes, and snippets.

@josiahwiebe
Created June 3, 2015 15:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save josiahwiebe/95d306f399132442154d to your computer and use it in GitHub Desktop.
Save josiahwiebe/95d306f399132442154d to your computer and use it in GitHub Desktop.
Gulpfile with Sass error notify
var gulp = require('gulp'),
uglify = require('gulp-uglify'),
watch = require('gulp-watch'),
notify = require('gulp-notify'),
browserSync = require('browser-sync').create()
sass = require('gulp-sass'),
neat = require('node-neat').includePaths;
var paths = {
scripts: ['_src/js/**/*.js', '!dist/js/**/*.js'],
scss: ['_src/scss/**/*.scss']
};
gulp.task('serve', ['sass'], function() {
browserSync.init({
server: {
baseDir: './'
}
});
gulp.watch(paths.scss, ['sass']);
gulp.watch('*.html').on('change', browserSync.reload);
});
gulp.task('sass', function() {
gulp.src('_src/scss/*.scss')
.pipe(sass({
includePaths: ['sass'].concat(neat)
}))
.on('error', function(err) {
console.log(err.message);
return notify().write(err); // send the error through Growl
})
.pipe(gulp.dest('./dist/css'))
.pipe(browserSync.stream())
.pipe(notify('Sass compiled successfully.'))
});
gulp.task('js', function() {
gulp.src('_src/js/*.js')
.pipe(uglify())
.pipe(gulp.dest('dist/js'))
.pipe(notify('Finished minifying JS.'));
});
gulp.task('watch', function() {
gulp.watch(paths.scripts, ['js']);
});
gulp.task('default', ['serve', 'sass', 'js', 'watch']);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment