-
Notifications
You must be signed in to change notification settings - Fork 62
/
bundlers.js
47 lines (43 loc) · 1.52 KB
/
bundlers.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
var browserify = require('browserify')
var babelify = require('babelify')
var watchify = require('watchify')
var xtend = require('xtend')
var COMMON_SHARED_MODULES = [
{name: 'd3'},
{name: 'react'},
{name: 'numeric'},
{name: 'three'},
{name: 'color', alias: './client/scripts/src/color'},
{name: 'alphaify', alias: './client/scripts/src/alphaify'},
{name: 'puid', alias: './client/scripts/src/puid'},
{name: 'OrbitControls', alias: './third-party/OrbitControls'},
{name: 'TrackballControls', alias: './third-party/TrackballControls'},
{name: 'd3-masonic', alias: './third-party/d3-masonic'},
]
var bundlers = {}
bundlers.js = {}
bundlers.js.commonSharedModules = function commonSharedModules(opts) {
var bundle = browserify({debug: opts.debug})
COMMON_SHARED_MODULES.forEach(function(module) {
if (!module.alias) bundle.require(module.name)
else bundle.require(module.alias, {expose: module.name})
})
if (opts.minify) bundle.transform({global: true}, 'uglifyify')
return bundle
}
bundlers.js.explanationMain = function explanationMain(opts) {
var bundle
if (opts.watchify)
bundle = watchify(browserify(xtend(watchify.args, {debug: opts.debug})))
else bundle = browserify({debug: opts.debug})
COMMON_SHARED_MODULES.forEach(function(module) {
bundle.external(module.name)
})
// React + ES6ify.
bundle.transform(babelify.configure({
optional: ['runtime', 'es7.objectRestSpread'],
}))
if (opts.minify) bundle.transform({global: true}, 'uglifyify')
return bundle
}
module.exports = bundlers