From 4bf8bdd3a0fdb59297c13e45db6306a5c0110989 Mon Sep 17 00:00:00 2001 From: Soulter <905617992@qq.com> Date: Thu, 10 Sep 2026 22:58:25 +0800 Subject: [PATCH] perf(dashboard): reduce bundled font and diagram assets --- dashboard/vite.config.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/dashboard/vite.config.ts b/dashboard/vite.config.ts index fef80e4367..e61c13b8ec 100644 --- a/dashboard/vite.config.ts +++ b/dashboard/vite.config.ts @@ -61,6 +61,18 @@ export default defineConfig(({ command }) => ({ // Only run MDI subsetting during production builds, skip in dev server ...(command === 'build' ? [mdiSubset()] : []), t2iShikiRuntimeAsset(), + { + name: 'katex-woff2-only', + enforce: 'pre', + transform(source, id) { + if (!/\/katex\/dist\/katex(?:\.min)?\.css$/.test(id.split('?')[0])) return; + // Keep one font format per face instead of shipping three identical glyph sets. + return source.replace(/src:[^;}]+/g, (declaration) => { + const woff2 = declaration.match(/url\([^)]*\.woff2\)\s*format\(["']woff2["']\)/); + return woff2 ? `src:${woff2[0]}` : declaration; + }); + }, + }, vue({ template: { compilerOptions: { @@ -83,10 +95,6 @@ export default defineConfig(({ command }) => ({ find: /^stream-monaco$/, replacement: fileURLToPath(new URL('./src/utils/streamMonacoDisabled.js', import.meta.url)) }, - { - find: 'mermaid', - replacement: 'mermaid/dist/mermaid.js' - }, { find: '@', replacement: fileURLToPath(new URL('./src', import.meta.url))