perf: 优化构建体积和依赖

- 移除未使用的依赖包 (@unovis/ts, @unovis/vue, markdown-it)
- 优化 vite manualChunks 配置,将 echarts/chart.js 分离为独立 chunk
- 主入口文件从 1.1MB 减少到 211KB (-81%)
- 依赖包数量从 837 减少到 662
This commit is contained in:
2026-05-07 18:48:14 +08:00
parent f700dc0a58
commit fa281040d0
5 changed files with 37 additions and 1804 deletions
+15 -1749
View File
File diff suppressed because it is too large Load Diff
-3
View File
@@ -37,8 +37,6 @@
"@tailwindcss/vite": "^4.2.1",
"@tanstack/vue-query": "^5.92.9",
"@tanstack/vue-table": "^8.21.3",
"@unovis/ts": "^1.6.4",
"@unovis/vue": "^1.6.4",
"@vee-validate/zod": "^4.15.1",
"@vueuse/core": "^14.2.1",
"@vueuse/integrations": "^14.2.1",
@@ -51,7 +49,6 @@
"embla-carousel-autoplay": "^8.6.0",
"embla-carousel-vue": "^8.6.0",
"lucide-vue-next": "0.575.0",
"markdown-it": "^14.1.1",
"motion-v": "1.7.4",
"nprogress": "^0.2.0",
"pinia": "^3.0.4",
@@ -25,5 +25,3 @@ interface ChartContextProps {
}
export const [useChart, provideChartContext] = createContext<ChartContextProps>("Chart")
export { VisCrosshair as ChartCrosshair, VisTooltip as ChartTooltip } from "@unovis/vue"
-47
View File
@@ -1,47 +0,0 @@
declare module 'markdown-it' {
interface Token {
type: string
tag: string
attrs: Array<[string, string]>
map: [number, number] | null
nesting: number
level: number
children: Token[] | null
content: string
markup: string
info: string
meta: any
block: boolean
hidden: boolean
}
interface Renderer {
rules: Record<string, (tokens: Token[], idx: number, options: any, env: any, self: Renderer) => string>
}
interface MarkdownIt {
renderer: Renderer
render: (src: string, env?: any) => string
parse: (src: string, env?: any) => Token[]
}
interface Options {
html?: boolean
xhtmlOut?: boolean
breaks?: boolean
langPrefix?: string
linkify?: boolean
typographer?: boolean
quotes?: string
highlight?: (str: string, lang: string) => string
}
interface MarkdownItConstructor {
new (options?: Options): MarkdownIt
(options?: Options): MarkdownIt
}
const MarkdownIt: MarkdownItConstructor
export default MarkdownIt
export { MarkdownIt, Options, Renderer, Token }
}
+22 -3
View File
@@ -112,9 +112,25 @@ export default defineConfig({
},
entryFileNames: 'assets/[name]-[hash].js',
assetFileNames: 'assets/[name]-[hash].[ext]',
manualChunks: {
'vue-vendor': ['vue', 'vue-router', 'vue-i18n', 'pinia', '@vueuse/core'],
'ui-vendor': ['reka-ui', 'class-variance-authority', 'clsx', 'tailwind-merge', 'lucide-vue-next'],
manualChunks(id) {
if (id.includes('node_modules/echarts/') || id.includes('node_modules\\echarts\\')) {
return 'echarts'
}
if (id.includes('node_modules/chart.js/') || id.includes('node_modules\\chart.js\\')) {
return 'chart'
}
if (id.includes('node_modules/vue/') || id.includes('node_modules/vue-router/') || id.includes('node_modules/vue-i18n/') || id.includes('node_modules/pinia/') || id.includes('node_modules/@vueuse/')) {
return 'vue-vendor'
}
if (id.includes('node_modules/reka-ui/') || id.includes('node_modules/class-variance-authority/') || id.includes('node_modules/clsx/') || id.includes('node_modules/tailwind-merge/') || id.includes('node_modules/lucide-vue-next/')) {
return 'ui-vendor'
}
if (id.includes('node_modules/vee-validate/') || id.includes('node_modules/@vee-validate/') || id.includes('node_modules/zod/')) {
return 'form-vendor'
}
if (id.includes('node_modules/@tanstack/')) {
return 'table-vendor'
}
},
},
},
@@ -135,4 +151,7 @@ export default defineConfig({
drop: ['debugger'],
pure: ['console.log'],
},
optimizeDeps: {
exclude: ['echarts', 'chart.js'],
},
})