-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathvite.config.ts
More file actions
79 lines (78 loc) · 2.12 KB
/
Copy pathvite.config.ts
File metadata and controls
79 lines (78 loc) · 2.12 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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import react from "@vitejs/plugin-react";
import dts from "vite-plugin-dts";
import { defineConfig } from "vitest/config";
export default defineConfig({
plugins: [
react(),
dts({
tsconfigPath: "./tsconfig.build.json",
include: ["src/**/*.ts", "src/**/*.tsx"],
exclude: ["src/**/*.test.ts", "src/**/*.test.tsx", "src/test/**"],
outDir: "dist",
insertTypesEntry: false, // We manually set types in package.json
}),
],
build: {
lib: {
entry: "./src/index.tsx", // Ensure this exists
name: "DynamicUI",
formats: ["es", "cjs"],
fileName: (format) => `index.${format}.js`,
},
// Target modern browsers for smaller bundles
target: "es2020",
// Enable CSS code splitting
cssCodeSplit: true,
// Enable minification
minify: "esbuild",
rollupOptions: {
external: (id) => {
// Externalize all React-related imports
return (
id === "react" ||
id === "react-dom" ||
id.startsWith("react/") ||
id.startsWith("react-dom/")
);
},
output: {
exports: "named",
// Manual chunk splitting for better caching
manualChunks: (id) => {
// Separate PatternFly into its own chunk
if (
id.includes("@patternfly/react-core") ||
id.includes("@patternfly/react-charts") ||
id.includes("@patternfly/react-table") ||
id.includes("@patternfly/react-data-view")
) {
return "patternfly";
}
},
globals: {
react: "React",
"react-dom": "ReactDOM",
"react/jsx-runtime": "React",
"react/jsx-dev-runtime": "React",
"react-dom/client": "ReactDOM",
},
},
},
},
test: {
globals: true,
environment: "jsdom",
setupFiles: "./src/test/setup.tsx",
coverage: {
provider: "v8",
reporter: ["text", "json", "html", "lcov"],
exclude: [
"node_modules/",
"src/test/",
"**/*.test.{ts,tsx}",
"**/*.config.{ts,js}",
"dist/",
],
},
},
});