mirror of
https://github.com/electron-vite/electron-vite-vue
synced 2025-01-19 11:56:36 +08:00
support debug
This commit is contained in:
parent
b3ee5e15d9
commit
e06b90e612
@ -2,6 +2,9 @@ import { spawn } from 'child_process'
|
||||
import { createServer, build } from 'vite'
|
||||
import electron from 'electron'
|
||||
|
||||
const query = new URLSearchParams(import.meta.url.split('?')[1])
|
||||
const debug = query.has('debug')
|
||||
|
||||
/**
|
||||
* @type {(server: import('vite').ViteDevServer) => Promise<import('rollup').RollupWatcher>}
|
||||
*/
|
||||
@ -15,17 +18,21 @@ function watchMain(server) {
|
||||
VITE_DEV_SERVER_HOST: address.address,
|
||||
VITE_DEV_SERVER_PORT: address.port,
|
||||
})
|
||||
|
||||
return build({
|
||||
configFile: 'packages/main/vite.config.ts',
|
||||
mode: 'development',
|
||||
plugins: [{
|
||||
/**
|
||||
* @type {import('vite').Plugin}
|
||||
*/
|
||||
const startElectron = {
|
||||
name: 'electron-main-watcher',
|
||||
writeBundle() {
|
||||
electronProcess && electronProcess.kill()
|
||||
electronProcess = spawn(electron, ['.'], { stdio: 'inherit', env })
|
||||
},
|
||||
}],
|
||||
}
|
||||
|
||||
return build({
|
||||
configFile: 'packages/main/vite.config.ts',
|
||||
mode: 'development',
|
||||
plugins: [!debug && startElectron].filter(Boolean),
|
||||
build: {
|
||||
watch: true,
|
||||
},
|
||||
|
Loading…
x
Reference in New Issue
Block a user