-
-
Save jonathanbp/cbb624892976fa71f59b 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
// Paths | |
var paths = { | |
sources: "./src/**/*.js", | |
sourceMain: "./src/index.js", | |
tests: "./test/*.js", | |
styles: "./styles", | |
target: "./dist", | |
targetMain: "bundle.js", | |
targetMainMin: "bundle.min.js" | |
} | |
// Gulp Dependencies | |
var gulp = require('gulp'); | |
var rename = require('gulp-rename'); | |
// Build Dependencies | |
var browserify = require('gulp-browserify'); | |
var uglify = require('gulp-uglify'); | |
// Style Dependencies | |
var less = require('gulp-less'); | |
var prefix = require('gulp-autoprefixer'); | |
var minifyCSS = require('gulp-minify-css'); | |
// Development Dependencies | |
var jshint = require('gulp-jshint'); | |
// Test Dependencies | |
var mochaPhantomjs = require('gulp-mocha-phantomjs'); | |
/** TESTING **/ | |
gulp.task('lint', function() { | |
return gulp.src(paths.sources) | |
.pipe(jshint()) | |
.pipe(jshint.reporter('default')); | |
}); | |
gulp.task('browserify', ['lint'], function() { | |
return gulp.src(paths.sourceMain) | |
.pipe(browserify({ | |
insertGlobals: true | |
})) | |
.pipe(rename(paths.targetMain)) | |
.pipe(gulp.dest(paths.target)); | |
}); | |
gulp.task('test', ['browserify-test'], function() { | |
return gulp.src('test/index.html') | |
.pipe(mochaPhantomjs()); | |
}); | |
/** if Client JS changes, re-browserify client and then re-lint and re-browserify Test **/ | |
gulp.task('watch', function() { | |
gulp.watch(paths.sources, ['browserify', 'test']); | |
gulp.watch(path.tests, ['test']); | |
}); | |
gulp.task('uglify', ['browserify'], function() { | |
return gulp.src(paths.targetMain) | |
.pipe(uglify()) | |
.pipe(rename(paths.targetMainMin)) | |
.pipe(gulp.dest(paths.target)); | |
}); | |
gulp.task('build', ['uglify', 'minify']); | |
/** use in development **/ | |
gulp.task("watch-dev", function(){ | |
gulp.watch(paths.sources, ['browserify']); | |
gulp.watch(paths.styles, ['styles']); | |
}); | |
// Default Workflow | |
// TEST does the lintering and browserifying | |
gulp.task('default', ['test', 'build', 'watch']); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment