'use strict';
// https://github.com/gulpjs/gulp/blob/master/docs/recipes/fast-browserify-builds-with-watchify.md
var watchify = require('watchify');
var browserify = require('browserify');
var gulp = require('gulp');
var source = require('vinyl-source-stream');
var buffer = require('vinyl-buffer');
var gutil = require('gulp-util');
var sourcemaps = require('gulp-sourcemaps');
var assign = require('lodash.assign');

// add custom browserify options here
var customOpts = {
  entries: ['./client/js/app.js'],
  debug: true
};
var opts = assign({}, watchify.args, customOpts);
var b = watchify(browserify(opts));

// add transformations here
// i.e. b.transform(coffeeify);

gulp.task('default', bundle); // so you can run `gulp js` to build the file
b.on('update', bundle); // on any dep update, runs the bundler
b.on('log', gutil.log); // output build logs to terminal

function bundle() {
  return b.bundle()
    // log errors if they happen
    .on('error', gutil.log.bind(gutil, 'Browserify Error'))
    .pipe(source('bundle.js'))
    // optional, remove if you don't need to buffer file contents
    .pipe(buffer())
    // optional, remove if you dont want sourcemaps
    .pipe(sourcemaps.init({loadMaps: true})) // loads map from browserify file
       // Add transformation tasks to the pipeline here.
    .pipe(sourcemaps.write('./')) // writes .map file
    .pipe(gulp.dest('./client/build/'));
}

@@ -416,56 +416,196 @@
 );%0A%0A
-// add custom browserify options here%0Avar custom
+gulp.task('default', function()%7B%0A    return bundle();%0A%7D);%0A%0Agulp.task('watch', function()%7B%0A    return bundle(true);%0A%7D);%0A%0Afunction bundle(watch) %7B%0A    var b;%0A    var opts;%0A    var browserify
 Opts
@@ -609,16 +609,22 @@
 pts = %7B%0A
+      
   entrie
@@ -650,16 +650,22 @@
 p.js'%5D,%0A
+      
   debug:
@@ -674,14 +674,48 @@
 rue%0A
-%7D;%0Avar
+    %7D;%0A%0A    if (watch === true)%7B%0A       
  opt
@@ -748,24 +748,32 @@
 gs, 
-customOpts);%0Avar
+browserifyOpts);%0A       
  b =
@@ -805,209 +805,160 @@
 ));%0A
-%0A// add transformations here%0A// i.e. b.transform(coffeeify);%0A%0Agulp.task('default', bundle); // so you can run %60gulp js%60 to build the file%0Ab.on('update', bundle); // on any dep update, runs the bundler%0A
+        b.on('update', bundle); // on any dep update, runs the bundler%0A    %7D else %7B%0A        opts = customOpts;%0A        b = browserify(opts);%0A    %7D%0A%0A    
 b.on
@@ -1014,29 +1014,10 @@
 nal%0A
-%0Afunction bundle() %7B%0A
+  
   re
@@ -1036,16 +1036,20 @@
 e()%0A    
+ 
+   
 // log e
@@ -1069,16 +1069,20 @@
  happen%0A
+    
     .on(
@@ -1133,24 +1133,28 @@
 rror'))%0A    
+ 
+   
 .pipe(source
@@ -1164,24 +1164,28 @@
 undle.js'))%0A
+    
     // optio
@@ -1238,24 +1238,28 @@
 ontents%0A    
+ 
+   
 .pipe(buffer
@@ -1262,16 +1262,20 @@
 ffer())%0A
+    
     // o
@@ -1318,24 +1318,28 @@
 rcemaps%0A    
+ 
+   
 .pipe(source
@@ -1397,24 +1397,29 @@
 serify file%0A
+     
        // Ad
@@ -1463,16 +1463,20 @@
 e here.%0A
+    
     .pip
@@ -1517,24 +1517,28 @@
 s .map file%0A
+    
     .pipe(gu

Split out gulp watch task so heroku build finishes