-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
32 lines (30 loc) · 1.11 KB
/
vite.config.ts
File metadata and controls
32 lines (30 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import react from "@vitejs/plugin-react-swc";
import { defineConfig } from "vite";
import tsConfigPaths from "vite-tsconfig-paths";
// https://vite.dev/config/
export default defineConfig({
plugins: [react(), tsConfigPaths()],
build: {
rollupOptions: {
output: {
manualChunks(id) {
// Automatic vendor splitting that works with pnpm
if (id.includes("node_modules")) {
// Handle pnpm's .pnpm directory structure
if (id.includes(".pnpm")) {
// Extract package name from: .pnpm/package@version/node_modules/package
const match = id.match(/\.pnpm\/[^/]+\/node_modules\/([^/]+)/);
if (match) {
return match[1].replace("@", "").replace("/", "-");
}
}
// Fallback for regular node_modules structure
const parts = id.split("node_modules/")[1].split("/");
const packageName = parts[0].startsWith("@") ? `${parts[0]}/${parts[1]}` : parts[0];
return packageName.replace("@", "").replace("/", "-");
}
},
},
},
},
});