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 react from "@vitejs/plugin-react-swc";
|
||||||
import dotenv from "dotenv";
|
import { defineConfig, loadEnv } from "vite";
|
||||||
import path from "path";
|
|
||||||
import { defineConfig } from "vite";
|
|
||||||
import svgr from "vite-plugin-svgr";
|
import svgr from "vite-plugin-svgr";
|
||||||
import tsconfigPaths from "vite-tsconfig-paths";
|
import tsconfigPaths from "vite-tsconfig-paths";
|
||||||
import {
|
import {
|
||||||
|
|
@ -12,16 +10,14 @@ import {
|
||||||
} from "./src/customization/config-constants";
|
} from "./src/customization/config-constants";
|
||||||
|
|
||||||
export default defineConfig(({ mode }) => {
|
export default defineConfig(({ mode }) => {
|
||||||
dotenv.config({ path: path.resolve(__dirname, "../../.env") });
|
const env = loadEnv(mode, process.cwd(), "");
|
||||||
|
|
||||||
const apiRoutes = API_ROUTES || ["^/api/v1/", "/health"];
|
const apiRoutes = API_ROUTES || ["^/api/v1/", "/health"];
|
||||||
|
|
||||||
// Use environment variable to determine the target.
|
|
||||||
const 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(env.VITE_PORT) || PORT || 3000;
|
||||||
const port = Number(process.env.VITE_PORT) || PORT || 3000;
|
|
||||||
|
|
||||||
const proxyTargets = apiRoutes.reduce((proxyObj, route) => {
|
const proxyTargets = apiRoutes.reduce((proxyObj, route) => {
|
||||||
proxyObj[route] = {
|
proxyObj[route] = {
|
||||||
|
|
@ -34,16 +30,14 @@ export default defineConfig(({ mode }) => {
|
||||||
}, {});
|
}, {});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
basename: BASENAME || "",
|
base: BASENAME || "",
|
||||||
build: {
|
build: {
|
||||||
outDir: "build",
|
outDir: "build",
|
||||||
},
|
},
|
||||||
define: {
|
define: {
|
||||||
"process.env.BACKEND_URL": JSON.stringify(process.env.BACKEND_URL),
|
"process.env.BACKEND_URL": JSON.stringify(env.BACKEND_URL),
|
||||||
"process.env.ACCESS_TOKEN_EXPIRE_SECONDS": JSON.stringify(
|
"process.env.ACCESS_TOKEN_EXPIRE_SECONDS": JSON.stringify(env.ACCESS_TOKEN_EXPIRE_SECONDS),
|
||||||
process.env.ACCESS_TOKEN_EXPIRE_SECONDS,
|
"process.env.CI": JSON.stringify(env.CI),
|
||||||
),
|
|
||||||
"process.env.CI": JSON.stringify(process.env.CI),
|
|
||||||
},
|
},
|
||||||
plugins: [react(), svgr(), tsconfigPaths()],
|
plugins: [react(), svgr(), tsconfigPaths()],
|
||||||
server: {
|
server: {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue