38 lines
1.0 KiB
JavaScript
Raw Normal View History

2021-11-11 17:52:50 +08:00
process.env.NODE_ENV = 'production'
import { build as viteBuild } from 'vite'
2021-11-23 09:54:28 +08:00
import { build as electronBuild, Platform } from 'electron-builder'
2021-11-18 12:44:29 +01:00
import { config as builderConfig } from '../configs/electron-builder.config.mjs'
2021-11-11 17:52:50 +08:00
import chalk from 'chalk'
const TAG = chalk.bgBlue(' build.mjs ')
const viteConfigs = {
main: 'configs/vite-main.config.ts',
preload: 'configs/vite-preload.config.ts',
reactTs: 'configs/vite-renderer.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() {
2021-11-23 09:54:28 +08:00
return electronBuild({
config: builderConfig,
// if you want to build windows platform
// targets: Platform.WINDOWS.createTarget(),
}).then(result => {
console.log(TAG, 'files:', chalk.green(result))
})
2021-11-11 17:52:50 +08:00
}
// bootstrap
2021-11-23 09:54:28 +08:00
await buildElectron()
await packElectron()