Files
LoveLiveMusicPlayer-Next/electron.vite.config.ts
T
2026-08-08 23:41:19 +08:00

55 lines
1.3 KiB
TypeScript

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()],
resolve: {
alias: {
'@main': resolve('src/main'),
'@shared': resolve('src/shared')
}
}
},
preload: {
plugins: [externalizeDepsPlugin()],
resolve: {
alias: {
'@shared': resolve('src/shared')
}
}
},
renderer: {
// 绑定 IPv4,避免仅监听 ::1 导致 Electron 用 localhost(127.0.0.1) 连接被拒
// 注意:不要再写 hmr.port=5173,会另起 WS 占口导致热更新假连上、不推送
server: {
host: '127.0.0.1',
port: 5173,
strictPort: true,
...(watchOptions ? { watch: watchOptions } : {}),
hmr: {
protocol: 'ws',
host: '127.0.0.1'
}
},
resolve: {
alias: {
'@renderer': resolve('src/renderer/src'),
'@shared': resolve('src/shared')
}
},
plugins: [react()]
}
})