refactor: build based vite alternative rollup
This commit is contained in:
1 parent
27a059e5dd
commit
2273453449
8 files changed
+126
-277
No files matched your search
@@ -0,0 +1,40 @@
|
||||
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)
|
||||
}
|
||||
})()
|
||||
Reference in new issue
Block a user