2026-09-21 15:56:52 +08:00
|
|
|
|
import { defineConfig } from "vite";
|
|
|
|
|
|
import react from "@vitejs/plugin-react";
|
|
|
|
|
|
import tailwindcss from "@tailwindcss/vite";
|
|
|
|
|
|
import basicSsl from "@vitejs/plugin-basic-ssl";
|
|
|
|
|
|
|
|
|
|
|
|
// https://vite.dev/config/
|
|
|
|
|
|
export default defineConfig({
|
|
|
|
|
|
// 🚀 basicSsl 仅 dev(本地 HMR https)需要;生产 build 跳过,
|
|
|
|
|
|
// 避免服务器容器低熵环境下生成自签名证书导致 vite build 卡住
|
|
|
|
|
|
plugins: [
|
|
|
|
|
|
react(),
|
|
|
|
|
|
tailwindcss(),
|
|
|
|
|
|
...(process.env.NODE_ENV !== "production" ? [basicSsl()] : []),
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
|
|
|
|
// 🚀 构建优化:将第三方巨头独立分包,利用浏览器缓存
|
|
|
|
|
|
build: {
|
|
|
|
|
|
rollupOptions: {
|
|
|
|
|
|
output: {
|
|
|
|
|
|
manualChunks(id: string) {
|
|
|
|
|
|
if (id.includes("node_modules/react-dom") || id.includes("node_modules/react/") || id.includes("node_modules/scheduler")) return "vendor-react";
|
|
|
|
|
|
if (id.includes("node_modules/react-router")) return "vendor-react";
|
|
|
|
|
|
if (id.includes("node_modules/antd") || id.includes("node_modules/@ant-design")) return "vendor-antd";
|
|
|
|
|
|
if (id.includes("node_modules/html5-qrcode")) return "vendor-qrcode";
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
clearScreen: false,
|
|
|
|
|
|
server: {
|
|
|
|
|
|
host: "0.0.0.0",
|
|
|
|
|
|
port: 1420,
|
|
|
|
|
|
strictPort: true,
|
|
|
|
|
|
// Docker on Windows/WSL 必须用 polling 才能检测到文件变化
|
|
|
|
|
|
watch: {
|
|
|
|
|
|
usePolling: true,
|
|
|
|
|
|
ignored: ["**/src-tauri/**"],
|
|
|
|
|
|
},
|
|
|
|
|
|
proxy: {
|
|
|
|
|
|
"/api": {
|
2026-09-21 16:10:52 +08:00
|
|
|
|
target: "http://lica_backend:8000", // Docker 内部用服务名(LICA 实例)
|
2026-09-21 15:56:52 +08:00
|
|
|
|
changeOrigin: true,
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|