perf(构建): 拆分 vendor chunk,入口 3.9MB -> 204kB
vite.config 增加 manualChunks 按库拆分与 chunkSizeWarningLimit;china-division 换用不含街道级的 pca-code.json(省 1.75MB);CreatePendingOrderDialog 改为异步组件,xlsx/china-division 不再进首屏。构建告警清零。
This commit is contained in:
parent
457d4d23d6
commit
bb80fd7130
@ -7,9 +7,15 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import CreatePendingOrderDialog from '@/views/order/orderManagement/component/CreatePendingOrderDialog.vue'
|
import { defineAsyncComponent } from 'vue'
|
||||||
import CreateOrderFloatWidget from '@/views/order/orderManagement/component/CreateOrderFloatWidget.vue'
|
import CreateOrderFloatWidget from '@/views/order/orderManagement/component/CreateOrderFloatWidget.vue'
|
||||||
import { useCreateOrderSession } from '@/views/order/orderManagement/composables/useCreateOrderSession'
|
import { useCreateOrderSession } from '@/views/order/orderManagement/composables/useCreateOrderSession'
|
||||||
|
|
||||||
|
// 该弹窗静态引入了 xlsx / china-division(合计 ~550kB),而本组件位于布局首屏链路上;
|
||||||
|
// 改为异步组件按需加载,仅真正打开“新建订单”时才拉取对应 chunk。
|
||||||
|
const CreatePendingOrderDialog = defineAsyncComponent(
|
||||||
|
() => import('@/views/order/orderManagement/component/CreatePendingOrderDialog.vue')
|
||||||
|
)
|
||||||
|
|
||||||
const { dialogVisible, sessionActive } = useCreateOrderSession()
|
const { dialogVisible, sessionActive } = useCreateOrderSession()
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@ -1038,7 +1038,7 @@ import { useUserStore } from '@/stores/modules/user'
|
|||||||
import { getWavePlatformPrintData } from '@/api/order.print/orderprint'
|
import { getWavePlatformPrintData } from '@/api/order.print/orderprint'
|
||||||
import { orderPendingOrderList, orderPendingOrderDetail } from '@/api/order.pendingorder/orderpendingOrder'
|
import { orderPendingOrderList, orderPendingOrderDetail } from '@/api/order.pendingorder/orderpendingOrder'
|
||||||
import type { WavePlatformPrintDataPayload } from '@/api/order.print/orderprint'
|
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(
|
const props = withDefaults(
|
||||||
defineProps<{
|
defineProps<{
|
||||||
|
|||||||
@ -398,7 +398,7 @@ import type {
|
|||||||
WaveStrategyUpdateParams,
|
WaveStrategyUpdateParams,
|
||||||
WaveListRpcSort
|
WaveListRpcSort
|
||||||
} from '@/api/order.wave/orderwave'
|
} 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<{
|
const props = withDefaults(defineProps<{
|
||||||
/** 与路由 path 组合,隔离 ScanBox 筛选缓存 */
|
/** 与路由 path 组合,隔离 ScanBox 筛选缓存 */
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import pcasCodeData from 'china-division/dist/pcas-code.json'
|
import pcasCodeData from 'china-division/dist/pca-code.json'
|
||||||
import type {
|
import type {
|
||||||
ExpressInterfaceCreateParams,
|
ExpressInterfaceCreateParams,
|
||||||
ExpressInterfaceUpdateParams
|
ExpressInterfaceUpdateParams
|
||||||
|
|||||||
@ -74,5 +74,37 @@ export default defineConfig(({ mode }) => {
|
|||||||
'@': fileURLToPath(new URL('./src', import.meta.url))
|
'@': 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'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user