-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathvite.config.ts
97 lines (95 loc) · 2.2 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import viteCompression from "vite-plugin-compression";
import * as path from "path";
// @ts-ignore
import { dependencies } from "./package.json";
function renderChunks(deps: Record<string, string>) {
let chunks = {};
Object.keys(deps).forEach((key) => {
if (["react", "react-router-dom", "react-dom"].includes(key)) return;
chunks[key] = [key];
});
return chunks;
}
// https://vitejs.dev/config/
export default defineConfig({
server: {
proxy: {
"/api": {
target: "https://goat-dev.plan4better.de/api/v1",
changeOrigin: true,
rewrite: (path) => path.replace(/^\/api/, "")
}
}
},
plugins: [
react(),
viteCompression({
ext: ".br",
algorithm: "brotliCompress"
})
],
build: {
sourcemap: false,
rollupOptions: {
output: {
manualChunks: {
vendor: ["react", "react-router-dom", "react-dom"],
...renderChunks(dependencies)
}
}
},
target: "es2021",
cssTarget: "chrome80",
brotliSize: false,
chunkSizeWarningLimit: 1000
},
resolve: {
alias: [
{
find: "@types",
replacement: path.resolve(__dirname, "src/types")
},
{
find: "@common",
replacement: path.resolve(__dirname, "src/common")
},
{
find: "@assets",
replacement: path.resolve(__dirname, "src/assets")
},
{
find: "@utils",
replacement: path.resolve(__dirname, "src/utils")
},
{
find: "@pages",
replacement: path.resolve(__dirname, "src/pages")
},
{
find: "@styles",
replacement: path.resolve(__dirname, "src/styles")
},
{
find: "@context",
replacement: path.resolve(__dirname, "src/context")
},
{
find: "@api",
replacement: path.resolve(__dirname, "src/api")
},
{
find: "@hooks",
replacement: path.resolve(__dirname, "src/hooks")
},
{
find: "@resources",
replacement: path.resolve(__dirname, "src/resources")
}
]
},
define: {
"process.env": process.env
}
});