-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.js
36 lines (34 loc) · 1.07 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
global.Promise = require('pinkie-promise');
const browserify = require('browserify');
const fs = require('fs');
const UglifyJS = require('uglify-js');
Promise.all(['index.js'].map(runBuild)).catch(function (err) {
console.error(err);
}).then(function () {
console.log("Finished");
});
function runBuild (f) {
return new Promise(function (resolve, reject) {
console.log('Bundling', f);
var b = browserify('src/' + f, {
debug: false,
// noparse: [ 'three' ]
});
// b.transform(require('babelify').configure({ presets: 'es2015' }));
b.plugin(require('bundle-collapser/plugin'));
var transforms = [['glslify', { global: true }]];
transforms.forEach(function (t) {
b.transform(t);
});
b.bundle(function (err, src) {
if (err) return reject(err);
console.log('Compressing', f);
var result = UglifyJS.minify(src.toString(), { fromString: true });
console.log('Writing', f);
fs.writeFile('app/js/' + f, result.code, function (err) {
if (err) return reject(err);
resolve();
});
});
});
}