Created
June 3, 2015 15:23
-
-
Save josiahwiebe/95d306f399132442154d to your computer and use it in GitHub Desktop.
Gulpfile with Sass error notify
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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