2021-11-08 19:16:16 +08:00
|
|
|
process.env.NODE_ENV = 'production'
|
|
|
|
|
|
|
|
import { build as viteBuild } from 'vite'
|
|
|
|
import chalk from 'chalk'
|
|
|
|
|
|
|
|
const TAG = chalk.bgBlue('[build.mjs]')
|
|
|
|
|
|
|
|
const viteConfigs = {
|
2021-11-09 10:17:06 +08:00
|
|
|
main: 'configs/vite.main.ts',
|
|
|
|
preload: 'configs/vite.preload.ts',
|
2021-12-08 18:47:35 +08:00
|
|
|
renderer: 'configs/vite.renderer.ts',
|
2021-11-08 19:16:16 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
async function buildElectron() {
|
|
|
|
for (const [name, configPath] of Object.entries(viteConfigs)) {
|
|
|
|
console.group(TAG, name)
|
2021-12-09 09:16:48 +08:00
|
|
|
await viteBuild({
|
2021-12-07 21:32:17 +08:00
|
|
|
configFile: configPath,
|
|
|
|
mode: process.env.NODE_ENV,
|
2021-12-09 09:16:48 +08:00
|
|
|
})
|
2021-11-08 19:16:16 +08:00
|
|
|
console.groupEnd()
|
|
|
|
console.log() // for beautiful log.
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-23 09:55:28 +08:00
|
|
|
// bootstrap
|
|
|
|
await buildElectron()
|