gulpfile.js
function (options) {

  // This bundle is for our application
  var bundler = browserify({
    debug: options.debug, // Need that sourcemapping
    standalone: 'flux-react',
    // These options are just for Watchify
    cache: {}, packageCache: {}, fullPaths: options.watch
  })
    .require(require.resolve('./src/main.js'), { entry: true })
    .external('react');

  // The actual rebundle process
  var rebundle = function () {
    var start = Date.now();
    bundler.bundle()
      .on('error', gutil.log)
      .pipe(source(options.name))
      .pipe(gulpif(options.uglify, streamify(uglify())))
      .pipe(gulp.dest(options.dest))
      .pipe(notify(function () {

        // Fix for requirejs
        var fs = require('fs');
        var file = fs.readFileSync(options.dest + '/' + options.name).toString();
        file = file.replace('define([],e)', 'define(["react"],e)');
        fs.writeFileSync(options.dest + '/' + options.name, file);

        console.log('Built in ' + (Date.now() - start) + 'ms');

      }));

  };

  // Fire up Watchify when developing
  if (options.watch) {
    bundler = watchify(bundler);
    bundler.on('update', rebundle);
  }

  return rebundle();

}
function (options) {

  // This bundle is for our application
  var bundler = browserify({
    debug: options.debug, // Need that sourcemapping
    standalone: 'flux-react',
    // These options are just for Watchify
    cache: {}, packageCache: {}, fullPaths: options.watch
  })
    .require(require.resolve('./src/main.js'), { entry: true })
    .external('react');

  // The actual rebundle process
  var rebundle = function () {
    var start = Date.now();
    bundler.bundle()
      .on('error', gutil.log)
      .pipe(source(options.name))
      .pipe(gulpif(options.uglify, streamify(uglify())))
      .pipe(gulp.dest(options.dest))
      .pipe(notify(function () {

        // Fix for requirejs
        var fs = require('fs');
        var file = fs.readFileSync(options.dest + '/' + options.name).toString();
        file = file.replace('define([],e)', 'define(["react"],e)');
        fs.writeFileSync(options.dest + '/' + options.name, file);

        console.log('Built in ' + (Date.now() - start) + 'ms');

      }));

  };

  // Fire up Watchify when developing
  if (options.watch) {
    bundler = watchify(bundler);
    bundler.on('update', rebundle);
  }

  return rebundle();

}
function ( options ) { // This bundle is for our application var bundler = browserify ( { debug : options . debug , // Need that sourcemapping standalone : 'flux-react' , // These options are just for Watchify cache : { } , packageCache : { } , fullPaths : options . watch } ) . require ( require . resolve ( './src/main.js' ) , { entry : true } ) . external ( 'react' ) ; // The actual rebundle process var rebundle = function ( ) { var start = Date . now ( ) ; bundler . bundle ( ) . on ( 'error' , gutil . log ) . pipe ( source ( options . name ) ) . pipe ( gulpif ( options . uglify , streamify ( uglify ( ) ) ) ) . pipe ( gulp . dest ( options . dest ) ) . pipe ( notify ( function ( ) { // Fix for requirejs var fs = require ( 'fs' ) ; var file = fs . readFileSync ( options . dest + '/' + options . name ) . toString ( ) ; file = file . replace ( 'define([],e)' , 'define(["react"],e)' ) ; fs . writeFileSync ( options . dest + '/' + options . name , file ) ; console . log ( 'Built in ' + ( Date . now ( ) - start ) + 'ms' ) ; } ) ) ; } ; // Fire up Watchify when developing if ( options . watch ) { bundler = watchify ( bundler ) ; bundler . on ( 'update' , rebundle ) ; } return rebundle ( ) ; }
The task that handles both development and deployment
The task that handles both development and deployment