Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 20 additions & 7 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,28 @@ export default defineConfig({
build: {
outDir: "../../dist/web",
emptyOutDir: true,
chunkSizeWarningLimit: 600,
rollupOptions: {
output: {
manualChunks: {
markdown: [
"react-markdown",
"remark-gfm",
"rehype-highlight",
"highlight.js",
],
manualChunks(id) {
if (!id.includes("node_modules")) return;

// React 核心:极少更新,长期缓存
if (/[\/](?:react-dom|react|scheduler)[\/]/.test(id)) {
return "framework";
}

// Markdown 渲染生态:体积大、独立功能
if (
/[\/](?:react-markdown|remark-[\w-]+|rehype-[\w-]+|highlight\.js|lowlight|parse5|unified|micromark[\w-]*|mdast[\w-]*|hast[\w-]*|vfile[\w-]*|unist[\w-]*|js-yaml|property-information|get-east-asian-width|markdown-table|comma-separated-tokens|space-separated-tokens|longest-streak|ccount|escape-string-regexp|trim-lines|decode-named-character-reference|html-void-elements|html-url-attributes|web-namespaces|inline-style-parser|style-to-object|style-to-js|is-plain-obj|bail|trough|zwitch|fault|extend|format)[\/]/.test(
id,
)
) {
return "markdown";
}

// 其余第三方依赖:偶尔更新
return "vendor";
},
},
},
Expand Down