Skip to content

Instantly share code, notes, and snippets.

@terakilobyte
Last active August 29, 2015 14:16
Show Gist options
  • Save terakilobyte/491f4e3916f2bdd5ee97 to your computer and use it in GitHub Desktop.
Save terakilobyte/491f4e3916f2bdd5ee97 to your computer and use it in GitHub Desktop.
browserify help
var paths = {
main: './client/client.js',
jsx: './common/components/**/*.jsx',
publicJs: './public/js',
server: './server/server.js',
serverIgnore: [
'gulpfile.js',
'public/',
'components/**/*.styl',
'bower_components/',
'node_modules/'
],
syncWatch: [
'public/**/*.*',
'!public/js/bundle.js'
]
};
var b = browserify(config);
bundleLogger.start('bundle.js');
b.transform(envify({
NODE_ENV: 'development'
}));
b = watchify(b);
b.on('update', function() {
bundleItUp(b);
});
b.on('time', function(time) {
if (!called) {
called = true;
cb();
}
debug('bundle completed in %s ms', time);
_reload();
});
b.on('error', function(e) {
debug('bundler error', e);
});
b.add(paths.main);
bundleItUp(b);
}
function bundleItUp(b) {
debug('Bundling');
return b.bundle()
.on('error', handleErrors)
.pipe(bundleName('bundle.js'))
.pipe(gulp.dest(paths.publicJs));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment