Skip to content

Commit

Permalink
split code to chunks
Browse files Browse the repository at this point in the history
  • Loading branch information
ShiboSoftwareDev committed Jan 11, 2025
1 parent 40469dd commit c47d0c6
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 30 deletions.
2 changes: 1 addition & 1 deletion biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"indentStyle": "space"
},
"files": {
"ignore": ["cosmos-export", "dist", "package.json"]
"ignore": ["cosmos-export", "dist", "package.json", ".vercel"]
},
"javascript": {
"formatter": {
Expand Down
59 changes: 30 additions & 29 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,17 @@ export default defineConfig(async (): Promise<UserConfig> => {
proxy: proxyConfig,
},
build: {
minify: true,
minify: "terser",
terserOptions: {
compress: {
drop_console: true,
drop_debugger: true,
passes: 2,
},
mangle: true,
format: {
comments: false,
},
},
reportCompressedSize: true,
rollupOptions: {
Expand All @@ -108,37 +112,34 @@ export default defineConfig(async (): Promise<UserConfig> => {
},
output: {
manualChunks(id) {
// Core React chunks
if (
id.includes("node_modules/react/") ||
id.includes("node_modules/react-dom/")
) {
return "react-core"
}

// CodeMirror chunks
if (id.includes("@codemirror/")) {
return "codemirror"
}

// Radix UI chunks
if (id.includes("@radix-ui/")) {
return "radix-ui"
}

// Circuit related chunks
if (id.includes("@tscircuit/") || id.includes("circuit-")) {
return "circuit-core"
}

// Other vendor chunks
if (id.includes("node_modules")) {
return "vendors"
if (id.includes("react/") || id.includes("react-dom/")) {
return "vendor-react"
}
if (id.includes("@codemirror/")) {
return "vendor-codemirror"
}
if (id.includes("@radix-ui/")) {
return "vendor-radix"
}
if (id.includes("@tscircuit/") || id.includes("circuit-")) {
return "vendor-circuit"
}
if (id.includes("three/") || id.includes("three-stdlib/")) {
return "vendor-three"
}
// Split remaining node_modules into smaller chunks
const chunk = id
.toString()
.split("node_modules/")[1]
.split("/")[0]
.toString()
return `vendor-${chunk}`
}
},
chunkFileNames: "assets/[name]-[hash].js",
entryFileNames: "assets/[name]-[hash].js",
assetFileNames: "assets/[name]-[hash][extname]",
chunkFileNames: "assets/js/[name]-[hash].js",
entryFileNames: "assets/js/[name]-[hash].js",
assetFileNames: "assets/[ext]/[name]-[hash][extname]",
},
},
},
Expand Down

0 comments on commit c47d0c6

Please sign in to comment.