-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.ts
60 lines (57 loc) · 1.54 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
import { defineConfig, loadEnv, splitVendorChunkPlugin } from "vite"
import react from "@vitejs/plugin-react"
import { resolve } from "path"
import viteCompression from 'vite-plugin-compression';
const getAliases = () => {
return {
"@assets": resolve("src/assets"),
"@components": resolve("src/infrastructure/components"),
"@domain": resolve("src/domain"),
"@pages": resolve("src/infrastructure/pages"),
}
}
export default defineConfig(({ command, mode }) => {
const env = loadEnv(mode, process.cwd())
if (command === "serve" && mode === "development") {
return {
plugins: [react(), viteCompression()],
resolve: {
alias: getAliases(),
},
server: {
port: parseInt(env.VITE_PORT),
},
build: {
outDir: "build",
chunkSizeWarningLimit: 2000,
minify: "esbuild",
rollupOptions: {
output: {
entryFileNames: `assets/[name].js`,
chunkFileNames: `assets/[name].js`,
assetFileNames: `assets/[name].[ext]`
}
}
}
}
} else {
return {
plugins: [react(), splitVendorChunkPlugin(), viteCompression()],
build: {
outDir: "build",
chunkSizeWarningLimit: 2000,
minify: "esbuild",
rollupOptions: {
output: {
entryFileNames: `assets/[name].js`,
chunkFileNames: `assets/[name].js`,
assetFileNames: `assets/[name].[ext]`
}
}
},
resolve: {
alias: getAliases(),
},
}
}
})