Skip to content

Instantly share code, notes, and snippets.

@szmeku
Last active August 29, 2015 14:10
Show Gist options
  • Save szmeku/e8a3ab9b4e1b4bf3ecae to your computer and use it in GitHub Desktop.
Save szmeku/e8a3ab9b4e1b4bf3ecae to your computer and use it in GitHub Desktop.
'use strict';
var gulp = require('gulp'),
gutil = require('gulp-util'),
source = require('vinyl-source-stream'),
browserify = require('browserify'),
debowerify = require('debowerify'),
watchify = require('watchify');
var distPath = './dist';
gulp.task('bundler-watch', function () {
var bundler = watchify(browserify('./src/main.js', {debug: true}).transform(debowerify));
bundler.on("log", function (msg) {
gutil.log(gutil.colors.green(msg));
});
bundler.on('update', rebundle);
function rebundle(file) {
if (file) {
file.map(function (fileName) {
gutil.log('File updated', gutil.colors.blue(fileName));
});
}
return bundler
.bundle()
.on("error", function (err) {
gutil.log("Browserify error:", err);
})
.pipe(source('bundle.js'))
.pipe(gulp.dest(distPath));
}
rebundle();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment