-
Notifications
You must be signed in to change notification settings - Fork 146
Expand file tree
/
Copy pathvite.config.js
More file actions
74 lines (70 loc) · 2.12 KB
/
Copy pathvite.config.js
File metadata and controls
74 lines (70 loc) · 2.12 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
68
69
70
71
72
73
74
import { defineConfig, loadEnv } from "vite";
import react from "@vitejs/plugin-react";
import tsconfigPaths from "vite-tsconfig-paths";
import svgr from "vite-plugin-svgr";
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd(), "");
// Expose VITE_ prefixed environment variables as process.env
const processEnv = Object.keys(env)
.filter((key) => key.startsWith("VITE_"))
.reduce((acc, key) => {
acc[`process.env.${key}`] = JSON.stringify(env[key]);
return acc;
}, {});
// Also expose MODE (Vite's built-in variable)
processEnv["process.env.MODE"] = JSON.stringify(mode);
return {
plugins: [
svgr(),
react(),
tsconfigPaths({
projects: ["./tsconfig.json"],
}),
],
define: {
global: "window",
...processEnv,
},
resolve: {
extensions: [".js", ".jsx", ".ts", ".tsx"],
},
server: {
port: 6010,
proxy: {
"^/etl": {
target: "http://localhost:8022",
changeOrigin: true,
secure: false,
rewrite: (path) => path.replace(/^\/etl/, ""),
},
"/chat": {
target: "http://localhost:8023",
changeOrigin: true,
secure: false,
},
"/dify-api": {
target: "https://api.dify.ai",
changeOrigin: true,
secure: true,
rewrite: (path) => path.replace(/^\/dify-api/, ""),
},
"^/(me|api|ai-assistant|web|search|config|idp-details|login|logout|auth|addressLevelType|locations|catchment|user|import|organisation|organisationConfig|subjectType|export|translation|account|forms|group|groups|concept|extension|viewsInDb|createReportingViews|groupPrivilege|implementation|individualRelationships|ruleDependency|rule|customCardConfigFile)":
{
target: process.env.BACKEND_URL,
changeOrigin: true,
secure: false,
},
},
},
build: {
outDir: "build",
sourcemap: true,
},
esbuild: {
target: "es2020",
},
ssr: {
noExternal: ["posthog-js", "posthog-js/react"],
},
};
});