Created
July 7, 2015 16:24
-
-
Save richardegil/9c513f8819e8ef25480c to your computer and use it in GitHub Desktop.
gulpfile.js
This file contains hidden or 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
// Gulp Requires | |
var gulp = require('gulp'), | |
plumber = require('gulp-plumber'), | |
// through = require('through-pipes'), | |
gutil = require('gulp-util'), | |
notify = require('gulp-notify'), | |
sass = require('gulp-sass'), | |
autoprefixer = require('gulp-autoprefixer'), | |
minifycss = require('gulp-minify-css'), | |
concat = require('gulp-concat'), | |
uglify = require('gulp-uglify'), | |
rename = require('gulp-rename'), | |
browserSync = require('browser-sync'), | |
// Node requires for exec and sys | |
exec = require('child_process').exec, | |
sys = require('sys'); | |
// Directories | |
var assets = 'assets', | |
cssSrc = assets + '/sass', | |
cssBuild = assets + '/css'; | |
gulp.task('browser-sync', function() { | |
browserSync({ | |
server: { | |
baseDir: "./" | |
} | |
}); | |
}); | |
gulp.task('bs-reload', function () { | |
browserSync.reload(); | |
}); | |
gulp.task('sass', function(){ | |
gulp.src([cssSrc + '/style.scss']) | |
// .pipe(plumber({ | |
// errorHandler: function (error) { | |
// console.log(error.message); | |
// this.emit('end'); | |
// }})) | |
.pipe(plumber({errorHandler: notify.onError("Error: <%= error.message %>")})) | |
.pipe(through(function () { | |
this.emit("error", new Error("Something happend: Error message!")) | |
})) | |
.pipe(sass()) | |
.pipe(autoprefixer('last 2 version', 'safari 5', 'ie 8', 'ie 9', 'opera 12.1', 'ios 6', 'android 4')) | |
.pipe(gulp.dest('assets/css/build/prefixed/')) | |
.pipe(minifycss()) | |
.pipe(gulp.dest('assets/css/build/minified/')) | |
.pipe(browserSync.reload({stream:true})) | |
}); | |
// Gulp Watcher | |
gulp.task('watch', ['browser-sync'], function() { | |
gulp.watch(cssSrc + '/**/*.scss ', ['sass']); | |
gulp.watch("*.html", ['bs-reload']); | |
gulp.watch("*.php", ['bs-reload']); | |
}); | |
// Gulp Default Task | |
gulp.task('default', ['sass', 'watch']); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment