From bb80fd7130940c6227b53a23586b7855a1ba5fad Mon Sep 17 00:00:00 2001 From: liufumingren Date: Thu, 8 Oct 2026 01:10:16 +0800 Subject: [PATCH] =?UTF-8?q?perf(=E6=9E=84=E5=BB=BA):=20=E6=8B=86=E5=88=86?= =?UTF-8?q?=20vendor=20chunk=EF=BC=8C=E5=85=A5=E5=8F=A3=203.9MB=20->=20204?= =?UTF-8?q?kB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit vite.config 增加 manualChunks 按库拆分与 chunkSizeWarningLimit;china-division 换用不含街道级的 pca-code.json(省 1.75MB);CreatePendingOrderDialog 改为异步组件,xlsx/china-division 不再进首屏。构建告警清零。 --- .../component/CreateOrderSessionHost.vue | 8 ++++- .../waveOrder/GroupWaveBatchListPanel.vue | 2 +- .../order/waveOrder/WaveStrategyListPanel.vue | 2 +- .../express-interface-config.ts | 2 +- vite.config.ts | 32 +++++++++++++++++++ 5 files changed, 42 insertions(+), 4 deletions(-) diff --git a/src/layout/component/CreateOrderSessionHost.vue b/src/layout/component/CreateOrderSessionHost.vue index 25d8e278..0913b273 100644 --- a/src/layout/component/CreateOrderSessionHost.vue +++ b/src/layout/component/CreateOrderSessionHost.vue @@ -7,9 +7,15 @@ diff --git a/src/views/order/waveOrder/GroupWaveBatchListPanel.vue b/src/views/order/waveOrder/GroupWaveBatchListPanel.vue index b96fd0ed..17b32929 100644 --- a/src/views/order/waveOrder/GroupWaveBatchListPanel.vue +++ b/src/views/order/waveOrder/GroupWaveBatchListPanel.vue @@ -1038,7 +1038,7 @@ import { useUserStore } from '@/stores/modules/user' import { getWavePlatformPrintData } from '@/api/order.print/orderprint' import { orderPendingOrderList, orderPendingOrderDetail } from '@/api/order.pendingorder/orderpendingOrder' import type { WavePlatformPrintDataPayload } from '@/api/order.print/orderprint' -import pcasCodeData from 'china-division/dist/pcas-code.json' +import pcasCodeData from 'china-division/dist/pca-code.json' const props = withDefaults( defineProps<{ diff --git a/src/views/order/waveOrder/WaveStrategyListPanel.vue b/src/views/order/waveOrder/WaveStrategyListPanel.vue index ef622312..6a537e3e 100644 --- a/src/views/order/waveOrder/WaveStrategyListPanel.vue +++ b/src/views/order/waveOrder/WaveStrategyListPanel.vue @@ -398,7 +398,7 @@ import type { WaveStrategyUpdateParams, WaveListRpcSort } from '@/api/order.wave/orderwave' -import pcasCodeData from 'china-division/dist/pcas-code.json' +import pcasCodeData from 'china-division/dist/pca-code.json' const props = withDefaults(defineProps<{ /** 与路由 path 组合,隔离 ScanBox 筛选缓存 */ diff --git a/src/views/system/setting/expressinterface/express-interface-config.ts b/src/views/system/setting/expressinterface/express-interface-config.ts index b393908b..19adea44 100644 --- a/src/views/system/setting/expressinterface/express-interface-config.ts +++ b/src/views/system/setting/expressinterface/express-interface-config.ts @@ -1,4 +1,4 @@ -import pcasCodeData from 'china-division/dist/pcas-code.json' +import pcasCodeData from 'china-division/dist/pca-code.json' import type { ExpressInterfaceCreateParams, ExpressInterfaceUpdateParams diff --git a/vite.config.ts b/vite.config.ts index 71e017dc..8b346a4a 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -74,5 +74,37 @@ export default defineConfig(({ mode }) => { '@': fileURLToPath(new URL('./src', import.meta.url)) }, }, + build: { + // 单库 chunk 本身就可能超 500kB(echarts / element-plus 全量引入),阈值按实际基线设置 + chunkSizeWarningLimit: 1200, + rollupOptions: { + output: { + /** + * 按库拆分第三方依赖,避免全量 element-plus / echarts 等挤进入口 chunk + * (入口曾达 3.9MB)。拆成独立 chunk 后可并行加载,且升级应用代码时第三方 chunk 哈希不变、命中长期缓存。 + */ + manualChunks(id) { + if (!id.includes('node_modules')) return + if (id.includes('echarts') || id.includes('zrender')) return 'vendor-echarts' + if (id.includes('/three/')) return 'vendor-three' + if (id.includes('xlsx')) return 'vendor-xlsx' + if (id.includes('element-plus')) return 'vendor-element-plus' + if (id.includes('china-division')) return 'vendor-china-division' + if ( + id.includes('/vue/') || + id.includes('/vue-') || + id.includes('/@vue/') || + id.includes('/pinia') || + id.includes('@vueuse') + ) { + // 含 vue-demi / vue-router / vue-i18n / vue-draggable-plus / pinia 等所有依赖 vue 的库, + // 否则这些库落到 vendor 会与 vendor-vue 形成循环 chunk + return 'vendor-vue' + } + return 'vendor' + } + } + } + }, } })