forked from playcanvas/engine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.mjs
43 lines (38 loc) · 1.07 KB
/
build.mjs
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
/**
* Build helper scripts
* Usage: node build.mjs [options] -- [rollup options]
*
* Options:
* target[:<moduleFormat>][:<buildType>][:<bundleState>] - Specify the target
* - moduleFormat (esm, umd)
* - buildType (release, debug, profiler, min)
* - bundleState (unbundled, bundled)
* Example: target:esm:release:bundled
*
* treemap - Enable treemap build visualization.
* treenet - Enable treenet build visualization.
* treesun - Enable treesun build visualization.
*/
import { execSync } from 'child_process';
const args = process.argv.slice(2);
const ENV_START_MATCHES = [
'target',
'treemap',
'treenet',
'treesun'
];
const env = [];
for (let i = 0; i < args.length; i++) {
if (ENV_START_MATCHES.some(match => args[i].startsWith(match)) && args[i - 1] !== '--environment') {
env.push(`--environment ${args[i]}`);
args.splice(i, 1);
i--;
continue;
}
}
const cmd = `rollup -c ${args.join(' ')} ${env.join(' ')}`;
try {
execSync(cmd, { stdio: 'inherit' });
} catch (e) {
console.error(e.message);
}