forked from playcanvas/engine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.mjs
38 lines (33 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
/**
* Build helper scripts
* Usage: node build.mjs [options] -- [rollup options]
*
* Options:
* target:<moduleFormat>:<buildType> - Specify the target module format and build type. Example: target:esm:release
* target:<moduleFormat> - Specify the target module format only. Example: target:esm
* target:<buildType> - Specify the build type only. Example: target:release
*
* 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(' ')}`;
console.log(cmd);
execSync(cmd, { stdio: 'inherit' });