Created
August 1, 2015 06:32
-
-
Save johnwheeler/465504987765ff095406 to your computer and use it in GitHub Desktop.
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 SRC_JS = 'client/js/**/*.js'; | |
var SRC_LESS = 'client/less/**/styles.less'; | |
var SRC_HTML = '*.html'; | |
var DEST_STYLES = 'static/styles/'; | |
var DEST_SCRIPTS = 'static/scripts/'; | |
var PROXY = 'localhost:8000'; | |
var gulp = require('gulp'); | |
var gutil = require('gulp-util'); | |
var jshint = require('gulp-jshint'); | |
var less = require('gulp-less'); | |
var sourcemaps = require('gulp-sourcemaps'); | |
var uglify = require('gulp-uglify'); | |
var concat = require('gulp-concat'); | |
var rename = require('gulp-rename'); | |
var cssmin = require('gulp-cssmin'); | |
var del = require('del'); | |
var browserSync = require('browser-sync').create(); | |
gulp.task('default', ['watch']); | |
gulp.task('clean', function() { | |
del([ | |
DEST_SCRIPTS, | |
DEST_STYLES | |
]); | |
}); | |
gulp.task('build', ['css', 'js']); | |
gulp.task('lint', function() { | |
return gulp.src(SRC_JS) | |
.pipe(jshint()) | |
.pipe(jshint.reporter('jshint-stylish')) | |
.pipe(jshint.reporter('fail')); | |
}); | |
gulp.task('js', ['lint'], function() { | |
return gulp.src(SRC_JS) | |
.pipe(sourcemaps.init()) | |
.pipe(concat('bundle.js')) | |
.pipe(uglify()) | |
.pipe(rename({suffix: '.min'})) | |
.pipe(sourcemaps.write('.')) | |
.pipe(gulp.dest(DEST_SCRIPTS)); | |
}); | |
gulp.task('css', function() { | |
return gulp.src(SRC_LESS) | |
.pipe(sourcemaps.init()) | |
.pipe(less()) | |
.pipe(cssmin()) | |
.pipe(rename({suffix: '.min'})) | |
.pipe(sourcemaps.write('.')) | |
.pipe(gulp.dest(DEST_STYLES)) | |
.pipe(browserSync.stream({match: '**/*.css'})); | |
}); | |
gulp.task('watch', function() { | |
browserSync.init({ | |
open: false, | |
notify: false, | |
proxy: PROXY | |
}); | |
gulp.watch(SRC_JS, ['js']); | |
gulp.watch(SRC_LESS, ['css']); | |
gulp.watch(SRC_HTML, browserSync.reload); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment