This commit is contained in:
parent
eddddc56ae
commit
4f39f428bd
@ -5,7 +5,7 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"tauri": "tauri",
|
"tauri": "tauri",
|
||||||
"dev:web": "vite",
|
"dev:web": "vite",
|
||||||
"dev:server": "node --experimental-strip-types --no-warnings server/index.js",
|
"dev:server": "node --watch --experimental-strip-types --no-warnings server/index.js",
|
||||||
"dev": "concurrently -n web,api -c blue,green \"npm run dev:web\" \"npm run dev:server\"",
|
"dev": "concurrently -n web,api -c blue,green \"npm run dev:web\" \"npm run dev:server\"",
|
||||||
"build": "vite build",
|
"build": "vite build",
|
||||||
"preview": "vite preview",
|
"preview": "vite preview",
|
||||||
|
|||||||
@ -2,16 +2,17 @@ import { defineConfig } from 'vite'
|
|||||||
import react from '@vitejs/plugin-react'
|
import react from '@vitejs/plugin-react'
|
||||||
|
|
||||||
// 移动端优先: 默认按移动视口开发, 同时兼容桌面浏览器
|
// 移动端优先: 默认按移动视口开发, 同时兼容桌面浏览器
|
||||||
// HMR 需要 WebSocket; 某些受限 webview (VS Code Simple Browser / 老版 Android WebView) 不支持.
|
// HMR 走 WebSocket; 某些受限 webview (VS Code Simple Browser / 老版 Android WebView) 不支持,
|
||||||
// 设置 hmr: false 后, Vite 会改用文件监听 + 页面全量刷新兜底, 在任何环境都能用.
|
// 此时 Vite 会自动降级为整页刷新兜底 (full-reload 与 HMR 共用同一 WS 通道)。
|
||||||
|
// 注意: 不能设 hmr: false —— 那会连 WS 通道一起关掉, 文件变更不再触发任何刷新。
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
plugins: [react()],
|
plugins: [react()],
|
||||||
server: {
|
server: {
|
||||||
host: '0.0.0.0',
|
host: '0.0.0.0',
|
||||||
port: 5173,
|
port: 5173,
|
||||||
hmr: false, // 关闭 WebSocket HMR, 改用 full-reload
|
hmr: true, // 开启 WebSocket HMR + full-reload 兜底
|
||||||
watch: {
|
watch: {
|
||||||
usePolling: true,
|
usePolling: true, // Windows 文件监听用轮询更可靠
|
||||||
interval: 300,
|
interval: 300,
|
||||||
},
|
},
|
||||||
proxy: {
|
proxy: {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user