Skip to content

Instantly share code, notes, and snippets.

@kingease
Forked from a-axton/gist:6aed74c9a69668902ffd
Last active August 29, 2015 14:12
Show Gist options
  • Select an option

  • Save kingease/8f149f3ecd0b2cf18e4f to your computer and use it in GitHub Desktop.

Select an option

Save kingease/8f149f3ecd0b2cf18e4f to your computer and use it in GitHub Desktop.

Revisions

  1. kingease revised this gist Jan 2, 2015. No changes.
  2. @a-axton a-axton created this gist May 25, 2014.
    37 changes: 37 additions & 0 deletions gistfile1.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,37 @@
    var browserify = require('browserify');
    var watchify = require('watchify');
    var reactify = require('reactify');
    var gulp = require('gulp');
    var handleErrors = require('../util/handleErrors');
    var source = require('vinyl-source-stream');

    function scripts(watch) {
    var bundler, rebundle;

    if(watch) {
    bundler = watchify('./app/scripts/app.js');
    } else {
    bundler = browserify('./app/scripts/app.js');
    }

    bundler.transform(reactify);

    rebundle = function() {
    var stream = bundler.bundle({debug: true});
    stream.on('error', handleErrors);
    stream = stream.pipe(source('app.js'));
    return stream.pipe(gulp.dest('./build/'));
    };

    bundler.on('update', rebundle);

    return rebundle();
    }

    gulp.task('browserify-build', function() {
    return scripts(false);
    });

    gulp.task('browserify-watch', function() {
    return scripts(true);
    });