Refactor AIPage and EQPage components to use lazy loading with PageSuspense for improved performance; update vite.config.ts to adjust chunking strategy and increase chunk size warning limit for better handling of large libraries.
This commit is contained in:
+12
-20
@@ -208,21 +208,27 @@ export default defineConfig({
|
||||
manualChunks(id) {
|
||||
if (!id.includes("node_modules")) return;
|
||||
|
||||
// Keep core runtime dependencies stable for better long-term caching.
|
||||
if (id.includes("node_modules/react/") || id.includes("node_modules/react-dom/")) {
|
||||
return "react-vendor";
|
||||
}
|
||||
if (id.includes("node_modules/wouter/")) {
|
||||
return "router-vendor";
|
||||
}
|
||||
|
||||
// Split large libraries into their own chunks to avoid a single huge entry bundle.
|
||||
if (id.includes("node_modules/echarts/")) return "echarts-vendor";
|
||||
if (id.includes("node_modules/recharts/")) return "recharts-vendor";
|
||||
if (id.includes("node_modules/framer-motion/")) return "motion-vendor";
|
||||
if (id.includes("node_modules/@radix-ui/")) return "radix-vendor";
|
||||
|
||||
// Group frequently used small UI helpers.
|
||||
// streamdown + shiki + mermaid (lazy-loaded with AIPage)
|
||||
if (
|
||||
id.includes("streamdown") ||
|
||||
id.includes("@shikijs/") ||
|
||||
id.includes("/shiki/") ||
|
||||
id.includes("mermaid")
|
||||
) {
|
||||
return "ai-markdown-vendor";
|
||||
}
|
||||
|
||||
if (
|
||||
id.includes("node_modules/lucide-react/") ||
|
||||
id.includes("node_modules/class-variance-authority/") ||
|
||||
@@ -231,25 +237,11 @@ export default defineConfig({
|
||||
) {
|
||||
return "ui-vendor";
|
||||
}
|
||||
|
||||
// Fall back to per-package vendor chunks.
|
||||
const packageMatch = id.match(
|
||||
/node_modules[\\/](?:\.pnpm[\\/][^\\/]+[\\/]node_modules[\\/])?(@?[^\\/]+(?:[\\/][^\\/]+)?)/,
|
||||
);
|
||||
const packagePath = packageMatch?.[1];
|
||||
if (!packagePath) return "vendor";
|
||||
|
||||
const packageName = packagePath.startsWith("@")
|
||||
? packagePath.split(/[\\/]/).slice(0, 2).join("_")
|
||||
: packagePath.split(/[\\/]/)[0];
|
||||
|
||||
return `vendor-${packageName}`;
|
||||
},
|
||||
// Prevent Rollup from merging manual chunks back into larger bundles.
|
||||
onlyExplicitManualChunks: true,
|
||||
},
|
||||
},
|
||||
chunkSizeWarningLimit: 500,
|
||||
// streamdown pulls full @shikijs/langs (~7 MB) + themes + mermaid; lazy-loaded with AIPage.
|
||||
chunkSizeWarningLimit: 15000,
|
||||
cssCodeSplit: true,
|
||||
},
|
||||
server: {
|
||||
|
||||
Reference in New Issue
Block a user