forked from patternfly/patternfly-react-seed
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.common.ts
More file actions
78 lines (73 loc) · 2.09 KB
/
vite.config.common.ts
File metadata and controls
78 lines (73 loc) · 2.09 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
import pluginReact from "@vitejs/plugin-react-swc";
import path from "path";
import { UserConfig, splitVendorChunkPlugin } from "vite";
import viteTsConfigPaths from "vite-tsconfig-paths";
import projectCommon from "./vite.config.constants";
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export const viteConfig = (projectConfig: Record<string, any>) => {
const viteBase = {
test: {
env: {
TZ: "UTC",
},
watch: false,
testTimeout: process.env.CI ? 15000 : 10000,
globals: true,
environment: "jsdom",
setupFiles: [path.resolve(__dirname, "setupTests.ts")],
clearMocks: true,
},
root: projectCommon.paths.app,
envDir: __dirname,
plugins: [
pluginReact({ devTarget: "es2022" }),
viteTsConfigPaths(),
splitVendorChunkPlugin(),
],
css: {
modules: {
localsConvention: "camelCaseOnly" as const,
},
},
};
const configuration: UserConfig = {
...viteBase,
server: {
host: projectCommon.server.host,
port: projectCommon.server.port,
open: true,
proxy: Object.assign(
{
"/websocket": {
target: `ws://127.0.0.1:8080/${projectConfig.remote.path}`,
ws: true,
cookiePathRewrite: projectConfig.remote.cookiePathRewrite,
},
},
),
},
build: {
emptyOutDir: true,
// Relative to the root
outDir: projectCommon.paths.build,
assetsInlineLimit: 0,
rollupOptions: {
output: {
manualChunks(id: string) {
if (id.includes("node_modules") && id.includes("victory")) {
return "victory";
}
if (id.includes("node_modules") && id.includes("d3")) {
return "d3";
}
// creating a chunk to react routes deps. Reducing the vendor chunk size
if (id.includes("react-router-dom") || id.includes("@remix-run") || id.includes("react-router")) {
return "router";
}
},
},
},
},
};
return configuration;
};