Skip to content

Instantly share code, notes, and snippets.

@darkyen
Created April 1, 2015 11:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save darkyen/8feb7d1ba5988d81b40d to your computer and use it in GitHub Desktop.
Save darkyen/8feb7d1ba5988d81b40d to your computer and use it in GitHub Desktop.
gulp.task('browserify', function(callback){
function createBundle(b_config){
var bundler = browserify(b_config.entry, {
debug: true
});
var bundle = function(){
// Create a logger when it starts logging
bundleLogger.start(b_config.outputName);
return bundler.bundle()
.on('error', handleErrors)
.pipe(source(b_config.outputName))
.pipe(gulp.dest(b_config.dest))
.on('end', reportFinsihed);
};
if( global.isWatching ){
// console.log("Uses watchify");
bundler = watchify(bundler);
bundler.on('update', bundle);
}
bundler.transform(to5);
var reportFinsihed = function(){
bundleLogger.end(b_config.outputName);
if( bundleQueueLen ){
bundleQueueLen --;
if( bundleQueueLen === 0 ){
callback();
}
}
};
bundle();
}
var bundleQueue = config.bundleConfigs;
var bundleQueueLen = bundleQueue.length;
bundleQueue.forEach(createBundle);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment