forked from tangrams/tangram
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.js
43 lines (30 loc) · 1.03 KB
/
build.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
/*jshint node: true */
'use strict';
var browserify = require('browserify'),
yargs = require('yargs'),
glob = require('glob'),
es6ify = require('es6ify');
var args = yargs.usage('Usage: $0 --debug --require --all').demand([]).argv;
function main() {
if (args.includeLet) {
es6ify.traceurOverrides = { blockBinding: true };
}
var bundle = browserify({ debug: true}).
add(es6ify.runtime).
transform(es6ify.configure(/^(?!.*node_modules)+.+\.js$/));
if ((args.require !== undefined) && (args.all !== undefined)) {
throw new Error('You must specify either the require or all option, not both.');
}
if (args.require !== undefined) {
bundle.require(require.resolve(args.require), { entry: true});
}
if (args.all !== undefined) {
glob.sync(args.all).forEach(function (file) {
bundle.add(file);
});
}
bundle.bundle().
on('error', function (err) { console.error(err); }).
pipe(process.stdout);
}
main();