Making browserify setup inline in gulpfile

This commit is contained in:
Jeff Avallone 2014-11-25 08:55:07 -05:00
parent 5c856d5b19
commit b8b98edbf5

View File

@ -1,9 +1,6 @@
var gulp = require('gulp'), var gulp = require('gulp'),
notify = require('gulp-notify'), notify = require('gulp-notify'),
plumber = require('gulp-plumber'), plumber = require('gulp-plumber'),
browserify = require('browserify'),
es6ify = require('es6ify'),
tap = require('gulp-tap'),
config = require('./config'); config = require('./config');
function errorHandler() { function errorHandler() {
@ -12,18 +9,6 @@ function errorHandler() {
}); });
} }
function browserifyPipe() {
return tap(function(file) {
var bundler = browserify(config.browserify);
bundler.add([file.path, es6ify.runtime]);
bundler.transform(require('./lib/canopy-transform'));
bundler.transform(es6ify);
file.contents = bundler.bundle();
});
}
gulp.task('default', ['server'], function() { gulp.task('default', ['server'], function() {
gulp.watch(config.globs.other, ['static']); gulp.watch(config.globs.other, ['static']);
gulp.watch([config.globs.html, config.templateFile], ['markup']); gulp.watch([config.globs.html, config.templateFile], ['markup']);
@ -70,9 +55,21 @@ gulp.task('compass', function() {
}); });
gulp.task('browserify', function() { gulp.task('browserify', function() {
var browserify = require('browserify'),
es6ify = require('es6ify'),
tap = require('gulp-tap');
return gulp.src('./src/js/main.js', { read: false }) return gulp.src('./src/js/main.js', { read: false })
.pipe(errorHandler()) .pipe(errorHandler())
.pipe(browserifyPipe()) .pipe(tap(function(file) {
var bundler = browserify(config.browserify);
bundler.add([file.path, es6ify.runtime]);
bundler.transform(require('./lib/canopy-transform'));
bundler.transform(es6ify);
file.contents = bundler.bundle();
}))
.pipe(gulp.dest('./build/js')); .pipe(gulp.dest('./build/js'));
}); });