Skip to content

Instantly share code, notes, and snippets.

@warlyware
Created August 25, 2015 19:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save warlyware/3efc4b200e1201bf8d42 to your computer and use it in GitHub Desktop.
Save warlyware/3efc4b200e1201bf8d42 to your computer and use it in GitHub Desktop.
Main gulpfile
var gulp = require('gulp');
var args = require('yargs').argv;
var config = require('./gulpconfig')();
var del = require('del');
var g = require('gulp-load-plugins')({lazy: true});
gulp.task('vet', function() {
log('[1] checking source files for errors');
return gulp.src(config.dir.js)
.pipe(g.if(args.verbose, g.print()))
.pipe(g.jshint())
.pipe(g.jshint.reporter('jshint-stylish', {verbose: true}))
.pipe(g.jshint.reporter('fail'));
});
gulp.task('css', ['clean-css'], function() {
log('[2] compiling less to css');
return gulp.src(config.dir.less)
.pipe(g.plumber())
.pipe(g.less())
.pipe(g.autoprefixer({browsers: ['last 2 version', '> 5%']}))
.pipe(gulp.dest(config.dir.temp));
});
gulp.task('clean-css', function(cb) {
var files = config.dir.temp + '/**/*.css';
clean(files, cb);
});
gulp.task('less-watcher', function() {
gulp.watch([config.dir.less], ['css']);
});
function clean(path, cb) {
log('Cleaning: ' + g.util.colors.blue(path));
del(path, cb);
}
function log(msg) {
if (typeof(msg) === 'object') {
for (var item in msg) {
if (msg.hasOwnProperty(item)) {
g.util.log(g.util.colors.blue(msg[item]));
}
}
} else {
g.util.log(g.util.colors.blue(msg));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment