Created
August 25, 2015 19:33
-
-
Save warlyware/3efc4b200e1201bf8d42 to your computer and use it in GitHub Desktop.
Main gulpfile
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
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