Skip to content

Commit bef992d

Browse files
committed
build: split the bundle into multiple chunks
1 parent 0114e61 commit bef992d

File tree

2 files changed

+67
-6
lines changed

2 files changed

+67
-6
lines changed

tailwind.config.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,5 @@ export default {
104104
);
105105
},
106106
],
107-
purge: {
108-
content: ["./{pages,components,app,src}/**/*.{ts,tsx}"],
109-
options: {
110-
safelist: ["cm-editor", "cm-gutter", "ͼ1", "cm-focused"],
111-
},
112-
},
107+
safelist: ["cm-editor", "cm-gutter", "ͼ1", "cm-focused"],
113108
};

vite.config.ts

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,72 @@ export default defineConfig({
2020
},
2121
build: {
2222
outDir: "build",
23+
rollupOptions: {
24+
output: {
25+
manualChunks: {
26+
// Core React dependencies (rarely change)
27+
vendor: ["react", "react-dom", "zustand"],
28+
29+
// Heavy parsing libraries (version-dependent)
30+
parsers: [
31+
"espree",
32+
"esquery",
33+
"@eslint/css",
34+
"@eslint/json",
35+
"@eslint/markdown",
36+
"@html-eslint/eslint-plugin",
37+
"eslint-linter-browserify",
38+
"eslint-scope",
39+
],
40+
41+
// UI framework components (stable)
42+
ui: [
43+
"@radix-ui/react-accordion",
44+
"@radix-ui/react-dialog",
45+
"@radix-ui/react-dropdown-menu",
46+
"@radix-ui/react-label",
47+
"@radix-ui/react-popover",
48+
"@radix-ui/react-select",
49+
"@radix-ui/react-slot",
50+
"@radix-ui/react-switch",
51+
"@radix-ui/react-toast",
52+
"@radix-ui/react-toggle",
53+
"@radix-ui/react-toggle-group",
54+
],
55+
56+
// Code editor (large, separate feature)
57+
editor: [
58+
"@uiw/react-codemirror",
59+
"codemirror",
60+
"@codemirror/lang-css",
61+
"@codemirror/lang-html",
62+
"@codemirror/lang-javascript",
63+
"@codemirror/lang-json",
64+
"@codemirror/lang-markdown",
65+
"@codemirror/language",
66+
"@lezer/highlight",
67+
],
68+
69+
// Utilities and styling (frequently changing)
70+
utils: [
71+
"clsx",
72+
"tailwind-merge",
73+
"class-variance-authority",
74+
"lucide-react",
75+
"use-debounced-effect",
76+
],
77+
78+
// Visualization libraries
79+
visualization: ["graphviz-react", "react-resizable-panels"],
80+
},
81+
chunkFileNames: "assets/[name]-[hash].js",
82+
entryFileNames: "assets/[name]-[hash].js",
83+
assetFileNames: "assets/[name]-[hash].[ext]",
84+
},
85+
},
86+
minify: "esbuild",
87+
chunkSizeWarningLimit: 1000,
88+
sourcemap: false,
2389
},
2490
esbuild: {
2591
keepNames: true,

0 commit comments

Comments
 (0)