-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathvite.config.mts
More file actions
67 lines (61 loc) · 1.51 KB
/
vite.config.mts
File metadata and controls
67 lines (61 loc) · 1.51 KB
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
import { defineConfig, loadEnv } from "vite";
import react from "@vitejs/plugin-react";
import path from "node:path";
// https://vitejs.dev/config/
export default defineConfig(({ mode }) => {
const env = { ...process.env, ...loadEnv(mode, __dirname, "") };
return {
root: "src",
base: "/",
define: {},
server: {
host: true,
proxy: {
// with options
[env.API_DOMAIN!]: {
target: env.API_PROXY_DOMAIN,
changeOrigin: true,
rewrite: (path) => path.replace(/^\/api/, ""),
},
},
},
resolve: {
alias: [
{
find: /^~/,
replacement: "",
},
{
find: "@",
replacement: path.resolve(__dirname, "src"),
},
],
extensions: [".mjs", ".js", ".ts", ".jsx", ".tsx", ".json", ".vue"],
},
publicDir: "./public",
plugins: [react()],
build: {
outDir: "../build",
rollupOptions: {
// Material ui's "use client" directive causes a warning.
// This function ignores those warnings.
// See https://github.com/rollup/rollup/issues/4699#issuecomment-1571555307
// for more information.
onwarn(warning, warn) {
if (
warning.code === "MODULE_LEVEL_DIRECTIVE" &&
warning.message.includes("use client")
) {
return;
}
warn(warning);
},
},
},
esbuild: {
define: {
this: "window",
},
},
};
});