forked from playcanvas/engine
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrollup.config.mjs
More file actions
47 lines (37 loc) · 1.18 KB
/
Copy pathrollup.config.mjs
File metadata and controls
47 lines (37 loc) · 1.18 KB
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
import { buildJSOptions, buildTypesOption } from './utils/rollup-build-target.mjs';
/** @import { RollupOptions } from 'rollup' */
const RED_OUT = '\x1b[31m';
const BOLD_OUT = '\x1b[1m';
const RESET_OUT = '\x1b[0m';
const BUILD_TYPES = /** @type {const} */ (['rel', 'dbg', 'prf', 'min']);
const MODULE_FORMATS = /** @type {const} */ (['umd', 'esm']);
const envBuild = process.env.build ? process.env.build.toLowerCase() : null;
function includeBuild(buildType, moduleFormat) {
return envBuild === null ||
envBuild === buildType ||
envBuild === moduleFormat ||
envBuild === `${moduleFormat}:${buildType}`;
}
/**
* @type {RollupOptions[]}
*/
const targets = [];
BUILD_TYPES.forEach((buildType) => {
MODULE_FORMATS.forEach((moduleFormat) => {
if (!includeBuild(buildType, moduleFormat)) {
return;
}
targets.push(...buildJSOptions({
moduleFormat,
buildType
}));
});
});
if (envBuild === null || envBuild === 'types') {
targets.push(buildTypesOption());
}
if (!targets.length) {
console.error(`${RED_OUT}${BOLD_OUT}No targets found${RESET_OUT}`);
process.exit(1);
}
export default targets;