fix(webui): keep syntax highlighting chunks acyclic
This commit is contained in:
+31
-26
@@ -2,6 +2,36 @@ import { defineConfig, loadEnv } from "vite";
|
||||
import react from "@vitejs/plugin-react";
|
||||
import path from "node:path";
|
||||
|
||||
export function webuiManualChunk(id: string): string | undefined {
|
||||
if (id.includes("node_modules/refractor/lang/")) {
|
||||
return;
|
||||
}
|
||||
// Refractor reaches this HAST helper through hastscript. Keeping it with
|
||||
// Refractor prevents syntax-highlight <-> markdown-vendor circular chunks.
|
||||
if (
|
||||
id.includes("node_modules/react-syntax-highlighter")
|
||||
|| id.includes("node_modules/refractor/core")
|
||||
|| id.includes("node_modules/hast-util-parse-selector")
|
||||
) {
|
||||
return "syntax-highlight";
|
||||
}
|
||||
if (
|
||||
id.includes("node_modules/react-markdown")
|
||||
|| id.includes("node_modules/remark-")
|
||||
|| id.includes("node_modules/rehype-")
|
||||
|| id.includes("node_modules/unified")
|
||||
|| id.includes("node_modules/mdast-")
|
||||
|| id.includes("node_modules/hast-")
|
||||
|| id.includes("node_modules/micromark")
|
||||
|| id.includes("node_modules/unist-")
|
||||
) {
|
||||
return "markdown-vendor";
|
||||
}
|
||||
if (id.includes("node_modules/katex")) {
|
||||
return "katex";
|
||||
}
|
||||
}
|
||||
|
||||
export default defineConfig(({ mode }) => {
|
||||
const env = loadEnv(mode, process.cwd(), "");
|
||||
const target = env.NANOBOT_API_URL ?? "http://127.0.0.1:8765";
|
||||
@@ -32,32 +62,7 @@ export default defineConfig(({ mode }) => {
|
||||
sourcemap: false,
|
||||
rollupOptions: {
|
||||
output: {
|
||||
manualChunks(id) {
|
||||
if (id.includes("node_modules/refractor/lang/")) {
|
||||
return;
|
||||
}
|
||||
if (
|
||||
id.includes("node_modules/react-syntax-highlighter")
|
||||
|| id.includes("node_modules/refractor/core")
|
||||
) {
|
||||
return "syntax-highlight";
|
||||
}
|
||||
if (
|
||||
id.includes("node_modules/react-markdown")
|
||||
|| id.includes("node_modules/remark-")
|
||||
|| id.includes("node_modules/rehype-")
|
||||
|| id.includes("node_modules/unified")
|
||||
|| id.includes("node_modules/mdast-")
|
||||
|| id.includes("node_modules/hast-")
|
||||
|| id.includes("node_modules/micromark")
|
||||
|| id.includes("node_modules/unist-")
|
||||
) {
|
||||
return "markdown-vendor";
|
||||
}
|
||||
if (id.includes("node_modules/katex")) {
|
||||
return "katex";
|
||||
}
|
||||
},
|
||||
manualChunks: webuiManualChunk,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user