-
Notifications
You must be signed in to change notification settings - Fork 5
/
vite.config.ts
71 lines (67 loc) · 1.86 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
import { defineConfig, loadEnv } from "vite";
import react from "@vitejs/plugin-react-swc";
import colors from "picocolors";
import { visualizer } from "rollup-plugin-visualizer";
import { nodePolyfills } from "vite-plugin-node-polyfills";
import progress from "vite-plugin-progress";
import tsconfigPaths from "vite-tsconfig-paths";
const ENV_PREFIX = "ENV_";
// https://vitejs.dev/config/
export default defineConfig(({ command, mode }) => {
const env = loadEnv(mode, process.cwd(), ENV_PREFIX);
return {
plugins: [
react(),
tsconfigPaths(),
{
...visualizer(),
apply: "build",
},
progress({
format: `${colors.green(colors.bold("Building"))} ${colors.cyan(
"[:bar]",
)} :percent`,
}),
nodePolyfills(),
],
envPrefix: ENV_PREFIX,
server: {
open: true,
port: 3000,
host: true,
cors: true,
// proxy: {
// "/api": {
// target: "http://localhost:8080",
// changeOrigin: true,
// rewrite: (path) => path.replace(/^\/api/, ""),
// configure: (proxy, options) => {
// proxy.on("proxyReq", (proxyReq, req, res) => {
// proxyReq.removeHeader("Referer");
// proxyReq.removeHeader("origin");
// });
// },
// },
// },
},
test: {
globals: true,
environment: "happy-dom",
setupFiles: "./src/test/setup.ts",
},
base: env.ENV_APP_BASE_URL,
build: {
outDir: "dist",
rollupOptions: {
output: {
manualChunks: {
react: ["react", "react-dom", "react-router-dom"],
},
chunkFileNames: "assets/js/[name]-[hash].js",
entryFileNames: "assets/js/[name]-[hash].js",
assetFileNames: "assets/[ext]/[name]-[hash].[ext]",
},
},
},
};
});