41 lines
1.0 KiB
JavaScript
41 lines
1.0 KiB
JavaScript
process.env.NODE_ENV = 'production'
|
|
|
|
import { build as viteBuild } from 'vite'
|
|
import { build as electronBuild2 } from 'electron-builder'
|
|
import { config as builderConfig } from './electron-builder.config.mjs'
|
|
import chalk from 'chalk'
|
|
|
|
const TAG = chalk.bgBlue('[build.mjs]')
|
|
|
|
const viteConfigs = {
|
|
main: 'src/main/vite.config.ts',
|
|
preload: 'src/preload/vite.config.ts',
|
|
reactTs: 'src/react-ts/vite.config.ts',
|
|
}
|
|
|
|
async function buildElectron() {
|
|
for (const [name, configPath] of Object.entries(viteConfigs)) {
|
|
console.group(TAG, name)
|
|
await viteBuild({ configFile: configPath, mode: process.env.NODE_ENV })
|
|
console.groupEnd()
|
|
console.log() // for beautiful log.
|
|
}
|
|
}
|
|
|
|
async function packElectron() {
|
|
return electronBuild2({ config: builderConfig })
|
|
.then(result => {
|
|
console.log(TAG, chalk.green(`electron-builder.build result - ${result}`))
|
|
})
|
|
}
|
|
|
|
; (async () => {
|
|
try {
|
|
await buildElectron()
|
|
await packElectron()
|
|
} catch (error) {
|
|
console.error(error)
|
|
process.exit(1)
|
|
}
|
|
})()
|