Provide function for manualChunks

Instead of hardcoding the manualChunks this allows us to reduce chunk
size of index, and make it more flexible for new dependencies.
This commit is contained in:
Sebastian Martinez
2024-05-14 16:52:53 +02:00
parent 06eafe9a42
commit 83041c3e52
+10 -26
View File
@@ -42,32 +42,16 @@ export default defineConfig({
outDir: "build",
rollupOptions: {
output: {
manualChunks: {
markdown: [
"@radicle/gray-matter",
"dompurify",
"hast-util-to-dom",
"hast-util-to-html",
"katex",
"marked",
],
syntax: ["@wooorm/starry-night"],
grammarsTsx: [
"@wooorm/starry-night/source.ts",
"@wooorm/starry-night/source.tsx",
],
grammars: [
"@wooorm/starry-night/source.python",
"@wooorm/starry-night/source.js",
"@wooorm/starry-night/source.perl",
"@wooorm/starry-night/source.haskell",
"@wooorm/starry-night/source.ruby",
"@wooorm/starry-night/source.css",
"@wooorm/starry-night/source.solidity",
"@wooorm/starry-night/source.cs",
"@wooorm/starry-night/source.swift",
],
dom: ["svelte", "twemoji"],
manualChunks: id => {
if (id.includes("lodash")) {
return "lodash";
} else if (id.includes("katex")) {
return "katex";
} else if (id.includes("node_modules")) {
return "vendor";
} else if (id.includes("components")) {
return "components";
}
},
},
},