-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvite.config.ts
35 lines (34 loc) · 936 Bytes
/
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
import path from "path";
import react from "@vitejs/plugin-react";
import { defineConfig } from "vite";
import dotenv from "dotenv";
export default defineConfig(({}) => {
dotenv.config();
const { VITE_BACKEND_PORT, VITE_BACKEND_NAME, VITE_BACKEND_PROTOCOL } =
process.env;
const protocol =
VITE_BACKEND_PROTOCOL === "https" || VITE_BACKEND_PROTOCOL === "http"
? VITE_BACKEND_PROTOCOL
: "http";
const VITE_BACKEND_URL = `${protocol}://${VITE_BACKEND_NAME}:${VITE_BACKEND_PORT}`;
return {
plugins: [react()],
resolve: {
alias: {
"@": path.resolve(__dirname, "./src"),
},
},
server: {
proxy: {
"/api": {
target: VITE_BACKEND_URL,
changeOrigin: true,
rewrite: (path) => path.replace(/^\/api/, ""),
},
},
},
define: {
"import.meta.env.VITE_BACKEND_PORT": process.env.VITE_BACKEND_PORT,
},
};
});