From b725599cb03825610eb503708c35c42f479c0097 Mon Sep 17 00:00:00 2001 From: duxingchen Date: Thu, 6 Aug 2026 17:34:00 +0800 Subject: [PATCH] =?UTF-8?q?perf(frontend):=20Vite=20=E6=9E=84=E5=BB=BA?= =?UTF-8?q?=E5=88=86=E5=8C=85=20=E2=80=94=20manualChunks=20=E6=8B=86?= =?UTF-8?q?=E5=88=86=20vendor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 将 react/react-dom/react-router-dom → vendor-react 将 antd/@ant-design/icons → vendor-antd 将 html5-qrcode → vendor-qrcode 第三方巨头的独立 chunk 可被浏览器长期缓存,业务代码更新时无需重新下载。 --- frontend/vite.config.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/frontend/vite.config.ts b/frontend/vite.config.ts index a8aceb2..356faad 100644 --- a/frontend/vite.config.ts +++ b/frontend/vite.config.ts @@ -7,6 +7,19 @@ import basicSsl from "@vitejs/plugin-basic-ssl"; export default defineConfig({ plugins: [react(), tailwindcss(), basicSsl()], + // 🚀 构建优化:将第三方巨头独立分包,利用浏览器缓存 + build: { + rollupOptions: { + output: { + manualChunks: { + "vendor-react": ["react", "react-dom", "react-router-dom"], + "vendor-antd": ["antd", "@ant-design/icons"], + "vendor-qrcode": ["html5-qrcode"], + }, + }, + }, + }, + clearScreen: false, server: { host: "0.0.0.0",