mirror of
https://github.com/electron-vite/electron-vite-vue
synced 2025-01-31 20:16:36 +08:00
chore: Improve start time
This commit is contained in:
parent
072a0791b1
commit
bbba3e1669
@ -18,7 +18,7 @@ const spinner = ora(`${TAG} Electron main build...`)
|
|||||||
; (async () => {
|
; (async () => {
|
||||||
if (argv.watch) {
|
if (argv.watch) {
|
||||||
// Wait on vite server launched
|
// Wait on vite server launched
|
||||||
await waitOn({ port: env.PORT as string })
|
const waitOnState = waitOn({ port: env.PORT as string })
|
||||||
|
|
||||||
const watcher = watch(opt)
|
const watcher = watch(opt)
|
||||||
let child: ChildProcess
|
let child: ChildProcess
|
||||||
@ -26,7 +26,9 @@ const spinner = ora(`${TAG} Electron main build...`)
|
|||||||
const log = chalk.green(`change -- ${filename}`)
|
const log = chalk.green(`change -- ${filename}`)
|
||||||
console.log(TAG, log)
|
console.log(TAG, log)
|
||||||
})
|
})
|
||||||
watcher.on('event', ev => {
|
watcher.on('event', async ev => {
|
||||||
|
await waitOnState
|
||||||
|
|
||||||
if (ev.code === 'END') {
|
if (ev.code === 'END') {
|
||||||
if (child) child.kill()
|
if (child) child.kill()
|
||||||
child = spawn(
|
child = spawn(
|
||||||
@ -52,4 +54,3 @@ const spinner = ora(`${TAG} Electron main build...`)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user