adapt windows
This commit is contained in:
@@ -2,6 +2,16 @@ import { resolve } from 'path'
|
||||
import { defineConfig, externalizeDepsPlugin } from 'electron-vite'
|
||||
import react from '@vitejs/plugin-react'
|
||||
|
||||
/** Windows 上原生 fs.watch 对部分盘符/杀软常漏事件,用轮询保证 HMR */
|
||||
const watchOptions =
|
||||
process.platform === 'win32'
|
||||
? {
|
||||
usePolling: true,
|
||||
interval: 150,
|
||||
awaitWriteFinish: { stabilityThreshold: 80, pollInterval: 40 }
|
||||
}
|
||||
: undefined
|
||||
|
||||
export default defineConfig({
|
||||
main: {
|
||||
plugins: [externalizeDepsPlugin()],
|
||||
@@ -22,9 +32,16 @@ export default defineConfig({
|
||||
},
|
||||
renderer: {
|
||||
// 绑定 IPv4,避免仅监听 ::1 导致 Electron 用 localhost(127.0.0.1) 连接被拒
|
||||
// 注意:不要再写 hmr.port=5173,会另起 WS 占口导致热更新假连上、不推送
|
||||
server: {
|
||||
host: '127.0.0.1',
|
||||
port: 5173
|
||||
port: 5173,
|
||||
strictPort: true,
|
||||
...(watchOptions ? { watch: watchOptions } : {}),
|
||||
hmr: {
|
||||
protocol: 'ws',
|
||||
host: '127.0.0.1'
|
||||
}
|
||||
},
|
||||
resolve: {
|
||||
alias: {
|
||||
|
||||
Reference in New Issue
Block a user