Last active
July 19, 2016 03:53
-
-
Save chrismcintosh/a08463c917fd14a304c1737fdac20bcc to your computer and use it in GitHub Desktop.
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
//Call The Package Dependencies | |
var gulp = require('gulp'); | |
var sass = require('gulp-sass'); | |
var sourcemaps = require('gulp-sourcemaps'); | |
var plumber = require('gulp-plumber'); | |
var concat = require('gulp-concat'); | |
var uglify = require('gulp-uglify'); | |
var rename = require('gulp-rename'); | |
var beep = require('beepbeep'); | |
//**************************** | |
// File Paths | |
//**************************** | |
var path = { | |
ALL: [ './assets/scss/*.scss', './assets/scss/**/*.scss' ], | |
SASS_SRC: [ './assets/scss/*.scss', './assets/scss/**/*.scss' ], | |
SASS_BUILD: './' | |
}; | |
//**************************** | |
// SASS | |
//**************************** | |
// Options | |
// - Output style: :nested:compact:expanded:compressed | |
var sassOptions = { | |
errLogToConsole: true, | |
outputStyle: 'expanded' | |
}; | |
var sassProduction = { | |
errLogToConsole: true, | |
outputStyle: 'compressed' | |
}; | |
gulp.task('sass', function () { | |
return gulp | |
.src(path.SASS_SRC) | |
.pipe(plumber({ | |
errorHandler: function (err) { | |
beep(2); | |
console.log(err); | |
this.emit('end'); | |
} | |
})) | |
.pipe(sourcemaps.init()) | |
.pipe(sass(sassOptions)) | |
.pipe(sourcemaps.write()) | |
.pipe(gulp.dest(path.SASS_BUILD)); | |
}); | |
//**************************** | |
// Watch | |
//**************************** | |
gulp.task('watch', function() { | |
gulp.watch(path.SASS_SRC, ['sass']) | |
.on('change', function(event) { | |
console.log('File ' + event.path + ' was ' + event.type + ', running tasks...'); | |
}); | |
}) | |
//**************************** | |
// Default Task | |
//**************************** | |
gulp.task('default', ['sass', 'watch']); | |
//**************************** | |
// Create Production Ready Assets | |
//**************************** | |
gulp.task('production', function() { | |
return gulp | |
.src(path.SASS_SRC) | |
.pipe(plumber({ | |
errorHandler: function (err) { | |
beep(2); | |
console.log(err); | |
this.emit('end'); | |
} | |
})) | |
.pipe(sass(sassProduction)) | |
.pipe(gulp.dest(path.SASS_BUILD)); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment