Created
June 30, 2014 09:18
-
-
Save tmoitie/a13f84e2dad99c42e3b6 to your computer and use it in GitHub Desktop.
Tom's bare minimum gulpfile
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
var gulp = require('gulp'); | |
var args = require('yargs').argv; | |
var gulpif = require('gulp-if'); | |
var rubysass = require('gulp-ruby-sass'); | |
var nodesass = require('gulp-sass'); | |
var prefix = require('gulp-autoprefixer'); | |
var minifycss = require('gulp-minify-css'); | |
var livereload = require('gulp-livereload'); | |
var fs = require('fs'); | |
var notify = require('gulp-notify'); | |
var lr = require('tiny-lr'); | |
var server = lr(); | |
var scssFiles = './sass/**/*.scss'; | |
var cssCompileDir = './css'; | |
var sassLoadPaths = [ | |
'./bower_components/bootstrap-sass-official/assets/stylesheets' | |
]; | |
var fastSass = args.fast === true; | |
function handleError(err) { | |
console.log(err.toString()); | |
this.emit('end'); | |
} | |
gulp.task('styles', function () { | |
gulp.src(scssFiles) | |
.pipe(gulpif(!fastSass, sass({ | |
sourcemap: true, | |
precision: 10, | |
loadPath: sassLoadPaths | |
}).on('error', handleError))) | |
.pipe(gulpif(fastSass, nodesass({ | |
errLogToConsole: true, | |
includePaths: sassLoadPaths | |
}))) | |
.pipe(prefix("last 1 version", "> 1%", "ie 8")) | |
.pipe(minifycss()) | |
.pipe(gulp.dest(cssCompileDir)) | |
.pipe(livereload(server)) | |
.pipe(notify({ message: 'SASS/Sourcemap compiled'})); | |
}); | |
gulp.task('watch', ['build'], function() { | |
server.listen(35729, function (err) { | |
if (err) { | |
throw err; | |
} | |
}); | |
gulp.watch(scssFiles, ['styles']); | |
}); | |
gulp.task('build', ['styles']); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Package.json deps