Skip to content

Instantly share code, notes, and snippets.

@maximilianschmitt
Created April 27, 2015 18:24
Show Gist options
  • Select an option

  • Save maximilianschmitt/80a0e1f0c8cb7a3301d6 to your computer and use it in GitHub Desktop.

Select an option

Save maximilianschmitt/80a0e1f0c8cb7a3301d6 to your computer and use it in GitHub Desktop.

Revisions

  1. maximilianschmitt created this gist Apr 27, 2015.
    38 changes: 38 additions & 0 deletions gulpfile.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,38 @@
    'use strict';

    var gulp = require('gulp');
    var browserify = require('browserify');
    var source = require('vinyl-source-stream');
    var notifier = require('stream-notifier');
    var watchify = require('watchify');

    gulp.task('browserify', function() {
    var bundler = browserify('./src/main')
    var bundle = compileBundle(bundler);

    return bundle();
    });

    gulp.task('watchify', function() {
    var opts = watchify.args;
    opts.debug = true;

    var bundler = watchify(browserify('./src/main', opts));
    var bundle = compileBundle(bundler)
    bundler.on('update', bundle);

    return bundle();
    });

    function compileBundle(bundler) {
    return function() {
    var n = notifier('browserify');

    return bundler
    .bundle()
    .on('error', n.error)
    .pipe(source('app.js'))
    .pipe(gulp.dest('dist'))
    .on('end', n.end);
    };
    }