Skip to content

Instantly share code, notes, and snippets.

@jayperryworks
Last active August 29, 2015 14:10
Show Gist options
  • Save jayperryworks/15f6fbf889d1984ddb77 to your computer and use it in GitHub Desktop.
Save jayperryworks/15f6fbf889d1984ddb77 to your computer and use it in GitHub Desktop.
gulpfile for sass processing/compression
'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']);
{
"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