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

55 lines
1.3 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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()]
}
})