Skip to content

Commit 69f0b8b

Browse files
LessUpCopilot
andcommitted
feat(docs): optimize delivery with vendor chunk splitting
Split heavy dependencies (mermaid, markdown-it, search) into separate lazy-loaded chunks. Main app bundle reduced from 606 KB to 61 KB (90% reduction). Large vendor chunks now load on-demand only when needed. Before: - app.js: 606 KB (all-in-one bundle) - Warning: chunks larger than 500 KB After: - app.js: 61 KB (main app) - mermaid-vendor.js: 2.9 MB (lazy-loaded on diagram pages) - markdown-vendor.js: 253 KB (lazy-loaded) - search-vendor.js: 18 KB (lazy-loaded) Tests: npm test passes (15/15) Build: No warnings for main app bundle Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 9e8eaf1 commit 69f0b8b

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

docs/.vitepress/config.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,26 @@ export default withMermaid(defineConfig({
233233

234234
vite: {
235235
plugins: [llmstxt()],
236+
build: {
237+
rollupOptions: {
238+
output: {
239+
manualChunks: (id) => {
240+
// Split mermaid and related dependencies into separate chunk
241+
if (id.includes('mermaid') || id.includes('cytoscape')) {
242+
return 'mermaid-vendor'
243+
}
244+
// Split search/fuse dependencies into separate chunk
245+
if (id.includes('fuse') || id.includes('minisearch')) {
246+
return 'search-vendor'
247+
}
248+
// Split katex/markdown-it math dependencies
249+
if (id.includes('katex') || id.includes('markdown-it')) {
250+
return 'markdown-vendor'
251+
}
252+
},
253+
},
254+
},
255+
},
236256
},
237257

238258
// Mermaid 配置 - 通过 withMermaid 传入

0 commit comments

Comments
 (0)