Skip to content

Instantly share code, notes, and snippets.

@tim-smart tim-smart/browserify-common.js Secret
Last active Dec 19, 2015

Embed
What would you like to do?
process.chdir(__dirname)
var browserify = require('browserify')
var mpath = require('path')
var common = browserify()
var other = browserify()
var package = require('./package.json')
var deps = Object.keys(package.dependencies)
// Custom deps
deps.push.apply(deps, package.customDependencies)
for (var i = 0, il = deps.length; i < il; i++) {
common.require(deps[i])
other.external(deps[i])
}
var bundle = null
switch (process.argv[2]) {
case 'common':
bundle = common
break
default:
bundle = other
other.add('./' + process.argv[2] + '.js')
break
}
bundle.bundle().pipe(process.stdout)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.