build(frontend): vite 支持 HXOPS_VITE_POLLING 轮询监听防改动丢失
This commit is contained in:
1 parent
60a8b20bf9
commit
81eeef944f
1 file changed
+7
@@ -6,6 +6,9 @@ import vue from '@vitejs/plugin-vue'
|
|||||||
const rootDir = path.dirname(fileURLToPath(import.meta.url))
|
const rootDir = path.dirname(fileURLToPath(import.meta.url))
|
||||||
const frontendPort = Number(process.env.HXOPS_FRONTEND_PORT || '8881')
|
const frontendPort = Number(process.env.HXOPS_FRONTEND_PORT || '8881')
|
||||||
const apiProxyTarget = process.env.HXOPS_API_PROXY_TARGET || 'http://127.0.0.1:5052'
|
const apiProxyTarget = process.env.HXOPS_API_PROXY_TARGET || 'http://127.0.0.1:5052'
|
||||||
|
// Windows 下杀软实时扫描/系统睡眠可能使文件事件丢失(表现为“改了不生效、刷新也拿旧代码”),
|
||||||
|
// 设置 HXOPS_VITE_POLLING=1 改用轮询监听:不依赖系统文件事件,稳定但略耗 CPU,按机器自选
|
||||||
|
const usePolling = process.env.HXOPS_VITE_POLLING === '1'
|
||||||
|
|
||||||
// https://vite.dev/config/
|
// https://vite.dev/config/
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
@@ -18,6 +21,10 @@ export default defineConfig({
|
|||||||
server: {
|
server: {
|
||||||
port: frontendPort, // 默认 8881,允许本地通过环境变量覆盖,避免与其它仓库冲突
|
port: frontendPort, // 默认 8881,允许本地通过环境变量覆盖,避免与其它仓库冲突
|
||||||
strictPort: true, // 端口被占用时直接失败,由 start_local.ps1 先释放旧进程
|
strictPort: true, // 端口被占用时直接失败,由 start_local.ps1 先释放旧进程
|
||||||
|
watch: {
|
||||||
|
usePolling,
|
||||||
|
interval: 300
|
||||||
|
},
|
||||||
allowedHosts: ['hx.benl.cn'],
|
allowedHosts: ['hx.benl.cn'],
|
||||||
proxy: {
|
proxy: {
|
||||||
'/api': {
|
'/api': {
|
||||||
|
|||||||
Reference in new issue
Block a user