Skip to content

Instantly share code, notes, and snippets.

@heroicyang
Created July 25, 2014 02:08
Show Gist options
  • Select an option

  • Save heroicyang/ef3eec8b36e0070b85e1 to your computer and use it in GitHub Desktop.

Select an option

Save heroicyang/ef3eec8b36e0070b85e1 to your computer and use it in GitHub Desktop.

Revisions

  1. heroicyang created this gist Jul 25, 2014.
    36 changes: 36 additions & 0 deletions gulpfile.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,36 @@
    var gulp = require('gulp');
    var source = require('vinyl-source-stream');
    var browserify = require('browserify');
    var watchify = require('watchify');

    gulp.task('setWatch', function() {
    global.isWatching = true;
    });

    gulp.task('browserify', function() {
    var bundleMethod = global.isWatching ? watchify : browserify;

    var bundler = bundleMethod({
    entries: ['./src/js/app.coffee'],
    extensions: ['coffee']
    });

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

    if(global.isWatching) {
    bundle.on('update', bundle);
    }

    return bundle();
    });

    gulp.task('watch', ['setWatch', 'browserify'], function() {
    // ...
    });

    gulp.task('default', ['watch']);