Last active
August 29, 2015 14:10
-
-
Save jayperryworks/15f6fbf889d1984ddb77 to your computer and use it in GitHub Desktop.
gulpfile for sass processing/compression
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
'use strict'; | |
var gulp = require('gulp'); | |
// load plugins | |
var $ = require('gulp-load-plugins')(); | |
// minifyCSS = require('gulp-minify-css'); | |
// useful file paths | |
var path = { | |
scss : 'theme/pcmoodle/style/scss/pc_style.scss', | |
css : 'theme/pcmoodle/style', | |
bower: 'bower_components' | |
}; | |
// tell me what the error is! | |
// -> prevent .pipe from dying on error w/ gulp-plumber | |
// -> and give more useful error messages | |
var showError = function(err) { | |
$.util.beep(); | |
console.log(err); | |
}; | |
gulp.task('styles', function () { | |
var reportOptions = { | |
err: true, | |
stderr: true, | |
stdout: true | |
}; | |
return gulp.src(path.scss) | |
.pipe($.plumber({ | |
errorHandler: showError | |
})) | |
.pipe($.rubySass({ | |
"sourcemap=none" : true, | |
style : 'nested', | |
lineNumbers : true, | |
bundleExec : true, | |
loadPath : path.bower | |
})) | |
.on('error', function (err) { console.log(err.message); }) | |
.pipe($.autoprefixer({ | |
browsers: ['> 1%'], | |
cascade: false, | |
remove: true | |
})) | |
.pipe($.exec.reporter(reportOptions)) | |
.pipe(gulp.dest(path.css)); | |
}); | |
gulp.task('deploy', ['styles'], function() { | |
return gulp.src(path.css + 'pc_style.css') | |
.pipe($.minifyCss({ | |
keepBreaks : false, | |
keepSpecialComments : 0 | |
})) | |
.pipe(gulp.dest(path.css)); | |
}); | |
gulp.task('watch', function() { | |
gulp.watch('./**/*.scss', ['styles']); | |
}); | |
gulp.task('default', ['styles', 'watch']); |
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
{ | |
"devDependencies": { | |
"gulp": "^3.8.10", | |
"gulp-autoprefixer": "^2.0.0", | |
"gulp-exec": "^2.1.1", | |
"gulp-load-plugins": "^0.7.1", | |
"gulp-minify-css": "^0.3.11", | |
"gulp-plumber": "^0.6.6", | |
"gulp-ruby-sass": "^0.7.1", | |
"gulp-util": "^3.0.1" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment