-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.js
42 lines (35 loc) · 1.06 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
#!/usr/bin/env node
const { build } = require("vite");
const { dirname } = require("path");
if (!process.env.MODE) process.env.MODE = "production";
/** @type 'production' | 'development' */
const mode = process.env.MODE;
const packagesConfigs = [
"packages/main/vite.config.js",
"packages/preload/vite.config.js",
"packages/renderer/vite.config.js",
];
/**
* Run `vite build` for config file
*/
const buildByConfig = (configFile) => build({ configFile, mode });
(async () => {
try {
const totalTimeLabel = "Total bundling time";
console.time(totalTimeLabel);
for (const packageConfigPath of packagesConfigs) {
const consoleGroupName = `${dirname(packageConfigPath)}/`;
console.group(consoleGroupName);
const timeLabel = "Bundling time";
console.time(timeLabel);
await buildByConfig(packageConfigPath);
console.timeEnd(timeLabel);
console.groupEnd();
console.log("\n"); // Just for pretty print
}
console.timeEnd(totalTimeLabel);
} catch (e) {
console.error(e);
process.exit(1);
}
})();