parent
3e11d8a64d
commit
d4bed03f9c
1 changed files with 9 additions and 15 deletions
|
|
@ -1,7 +1,5 @@
|
|||
import react from "@vitejs/plugin-react-swc";
|
||||
import dotenv from "dotenv";
|
||||
import path from "path";
|
||||
import { defineConfig } from "vite";
|
||||
import { defineConfig, loadEnv } from "vite";
|
||||
import svgr from "vite-plugin-svgr";
|
||||
import tsconfigPaths from "vite-tsconfig-paths";
|
||||
import {
|
||||
|
|
@ -12,16 +10,14 @@ import {
|
|||
} from "./src/customization/config-constants";
|
||||
|
||||
export default defineConfig(({ mode }) => {
|
||||
dotenv.config({ path: path.resolve(__dirname, "../../.env") });
|
||||
const env = loadEnv(mode, process.cwd(), "");
|
||||
|
||||
const apiRoutes = API_ROUTES || ["^/api/v1/", "/health"];
|
||||
|
||||
// Use environment variable to determine the target.
|
||||
const target =
|
||||
process.env.VITE_PROXY_TARGET || PROXY_TARGET || "http://127.0.0.1:7860";
|
||||
env.VITE_PROXY_TARGET || PROXY_TARGET || "http://127.0.0.1:7860";
|
||||
|
||||
// Use environment variable to determine the UI server port
|
||||
const port = Number(process.env.VITE_PORT) || PORT || 3000;
|
||||
const port = Number(env.VITE_PORT) || PORT || 3000;
|
||||
|
||||
const proxyTargets = apiRoutes.reduce((proxyObj, route) => {
|
||||
proxyObj[route] = {
|
||||
|
|
@ -34,16 +30,14 @@ export default defineConfig(({ mode }) => {
|
|||
}, {});
|
||||
|
||||
return {
|
||||
basename: BASENAME || "",
|
||||
base: BASENAME || "",
|
||||
build: {
|
||||
outDir: "build",
|
||||
},
|
||||
define: {
|
||||
"process.env.BACKEND_URL": JSON.stringify(process.env.BACKEND_URL),
|
||||
"process.env.ACCESS_TOKEN_EXPIRE_SECONDS": JSON.stringify(
|
||||
process.env.ACCESS_TOKEN_EXPIRE_SECONDS,
|
||||
),
|
||||
"process.env.CI": JSON.stringify(process.env.CI),
|
||||
"process.env.BACKEND_URL": JSON.stringify(env.BACKEND_URL),
|
||||
"process.env.ACCESS_TOKEN_EXPIRE_SECONDS": JSON.stringify(env.ACCESS_TOKEN_EXPIRE_SECONDS),
|
||||
"process.env.CI": JSON.stringify(env.CI),
|
||||
},
|
||||
plugins: [react(), svgr(), tsconfigPaths()],
|
||||
server: {
|
||||
|
|
@ -53,4 +47,4 @@ export default defineConfig(({ mode }) => {
|
|||
},
|
||||
},
|
||||
};
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue