2021-11-11 17:52:50 +08:00
|
|
|
process.env.NODE_ENV = 'production'
|
|
|
|
|
2022-01-27 10:48:32 +08:00
|
|
|
import { dirname, join } from 'path'
|
|
|
|
import { fileURLToPath } from 'url'
|
2022-01-27 12:22:16 +08:00
|
|
|
import { build } from 'vite'
|
2021-11-11 17:52:50 +08:00
|
|
|
|
2022-01-27 10:48:32 +08:00
|
|
|
const __dirname = dirname(fileURLToPath(import.meta.url))
|
2021-11-11 17:52:50 +08:00
|
|
|
|
2022-01-27 10:48:32 +08:00
|
|
|
/**
|
|
|
|
* @type {Record<string, import('vite').InlineConfig>}
|
|
|
|
*/
|
2021-11-11 17:52:50 +08:00
|
|
|
const viteConfigs = {
|
2022-01-27 10:48:32 +08:00
|
|
|
main: {
|
|
|
|
configFile: 'scripts/vite.config.mjs',
|
|
|
|
root: join(__dirname, '../src/main'),
|
|
|
|
build: {
|
|
|
|
outDir: '../../dist/main',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
preload: {
|
|
|
|
configFile: 'scripts/vite.config.mjs',
|
|
|
|
root: join(__dirname, '../src/preload'),
|
|
|
|
build: {
|
|
|
|
outDir: '../../dist/preload',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
renderer: {
|
|
|
|
configFile: 'src/renderer/vite.config.ts',
|
|
|
|
},
|
2021-11-11 17:52:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
async function buildElectron() {
|
2022-01-30 07:04:43 +08:00
|
|
|
for (const [, config] of Object.entries(viteConfigs)) {
|
2022-01-27 12:22:16 +08:00
|
|
|
await build(config)
|
2021-11-11 17:52:50 +08:00
|
|
|
console.log() // for beautiful log.
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// bootstrap
|
2021-11-23 09:54:28 +08:00
|
|
|
await buildElectron()
|