1
0
mirror of https://gitee.com/sui-feng-cb/AzurLaneAutoScript1 synced 2026-03-09 12:49:03 +08:00
AzurLaneAutoScript/webapp/scripts/build.js

44 lines
1.0 KiB
JavaScript
Raw Permalink Normal View History

2024-06-05 23:20:28 +08:00
#!/usr/bin/node
const {build} = require('vite');
const {dirname} = require('path');
/** @type 'production' | 'development' | 'test' */
2025-09-03 13:59:51 +08:00
const mode = process.env.MODE = process.env.MODE || 'production';
2024-06-05 23:20:28 +08:00
const packagesConfigs = [
'packages/main/vite.config.js',
'packages/preload/vite.config.js',
'packages/renderer/vite.config.js',
];
2025-09-03 13:59:51 +08:00
2024-06-05 23:20:28 +08:00
/**
* Run `vite build` for config file
*/
2025-09-03 13:59:51 +08:00
const buildByConfig = (configFile) => build({configFile, mode});
2024-06-05 23:20:28 +08:00
(async () => {
try {
const totalTimeLabel = 'Total bundling time';
console.time(totalTimeLabel);
for (const packageConfigPath of packagesConfigs) {
2025-09-03 13:59:51 +08:00
2024-06-05 23:20:28 +08:00
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);
}
})();