-
Notifications
You must be signed in to change notification settings - Fork 50
/
vite.config.ts
52 lines (49 loc) · 1.53 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
/// <reference types="vitest" />
import { defineConfig, loadEnv } from "vite";
import react from "@vitejs/plugin-react-swc";
import * as path from "path";
import eslint from "vite-plugin-eslint";
const manualChunks = [
"@canonical/react-components",
"@canonical/maas-react-components",
"@canonical/macaroon-bakery",
"@/app/store/machine/slice",
];
// https://vitejs.dev/config/
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, "./");
return {
envDir: "./",
base: "/",
define: {
"process.env": env,
},
build: {
manifest: "asset-manifest.json",
outDir: "build",
rollupOptions: {
output: {
sanitizeFileName: false,
// Creates an object with sanitized camel-cased module names as keys and original module names as values.
// e.g.: { "canonicalReactComponents": ["@canonical/react-components"] }.
manualChunks: manualChunks.reduce((chunks, module) => {
const sanitizedModule = module
.replace(/(^|[-\/])(.)/g, (_, _separator, letter) =>
letter.toUpperCase()
)
.replace(/[^a-zA-Z0-9]/g, "")
.replace(/^./, (firstChar) => firstChar.toLowerCase());
chunks[sanitizedModule] = [module];
return chunks;
}, {}),
},
},
sourcemap: true,
},
plugins: [react(), eslint()],
server: { port: 8401, hmr: { port: 8402 } },
resolve: {
alias: { "@": path.resolve(__dirname, "src") },
},
};
});