-
Notifications
You must be signed in to change notification settings - Fork 2
/
vite.config.ts
64 lines (55 loc) · 1.5 KB
/
vite.config.ts
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
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import checker from "vite-plugin-checker";
import svgr from "vite-plugin-svgr";
const { version } = require("./package.json");
const NamedChunks = {
// These packages can create cirular references, so we need to give them their own files
shared: ["scheduler", "loose-envify", "js-tokens", "object-assign"],
"css-utils": ["clsx", "csstype"],
"babel-runtime": ["@babel/runtime"],
// End circular reference group
react: ["react", "react-dom", "react-is", "prop-types"],
emotion: ["@emotion"],
mui: ["@mui", "@popperjs/core"],
rxjs: ["rxjs"],
lodash: ["lodash"],
};
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
svgr(),
react(),
checker({ typescript: { root: ".", tsconfigPath: "./tsconfig.json" } }),
],
base: "/catalogue/",
resolve: {
alias: {
"@": "/src",
},
},
define: {
__APP_VERSION__: JSON.stringify(version),
},
build: {
rollupOptions: {
output: {
manualChunks: (id) => {
if (id.includes("/node_modules/")) {
// Check explicit groups
for (const [name, modules] of Object.entries(NamedChunks)) {
if (modules.some((x) => id.includes(`/node_modules/${x}/`))) {
return name;
}
}
// Everything else from node_modules is vendor
return "vendor";
}
},
},
},
},
server: {
port: 8080,
},
});