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 { createServer, build } from 'vite'
|
||||||
import electron from 'electron'
|
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>}
|
* @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_HOST: address.address,
|
||||||
VITE_DEV_SERVER_PORT: address.port,
|
VITE_DEV_SERVER_PORT: address.port,
|
||||||
})
|
})
|
||||||
|
/**
|
||||||
return build({
|
* @type {import('vite').Plugin}
|
||||||
configFile: 'packages/main/vite.config.ts',
|
*/
|
||||||
mode: 'development',
|
const startElectron = {
|
||||||
plugins: [{
|
|
||||||
name: 'electron-main-watcher',
|
name: 'electron-main-watcher',
|
||||||
writeBundle() {
|
writeBundle() {
|
||||||
electronProcess && electronProcess.kill()
|
electronProcess && electronProcess.kill()
|
||||||
electronProcess = spawn(electron, ['.'], { stdio: 'inherit', env })
|
electronProcess = spawn(electron, ['.'], { stdio: 'inherit', env })
|
||||||
},
|
},
|
||||||
}],
|
}
|
||||||
|
|
||||||
|
return build({
|
||||||
|
configFile: 'packages/main/vite.config.ts',
|
||||||
|
mode: 'development',
|
||||||
|
plugins: [!debug && startElectron].filter(Boolean),
|
||||||
build: {
|
build: {
|
||||||
watch: true,
|
watch: true,
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user