diff --git a/packages/web/vite.config.ts b/packages/web/vite.config.ts index 0d5277286..e782f81d8 100644 --- a/packages/web/vite.config.ts +++ b/packages/web/vite.config.ts @@ -1,31 +1,34 @@ import react from "@vitejs/plugin-react-swc"; -import { defineConfig } from "vite"; +import { defineConfig, loadEnv } from "vite"; import svgr from "vite-plugin-svgr"; -export default defineConfig({ - plugins: [svgr(), react({ jsxImportSource: "@emotion/react" })], - envDir: "../..", - envPrefix: "REACT_APP_", - resolve: { - alias: { - "@": "/src", - }, - }, - build: { - outDir: "./build", - }, - server: { - port: 3000, - host: true, - proxy: { - "/api": { - target: process.env.REACT_APP_BACK_URL ?? "http://localhost:9000", - rewrite: (path) => path.replace(/^\/api/, ""), +export default defineConfig(({ mode }) => { + const env = loadEnv(mode, "../..", "REACT_APP_"); + return { + plugins: [svgr(), react({ jsxImportSource: "@emotion/react" })], + envDir: "../..", + envPrefix: "REACT_APP_", + resolve: { + alias: { + "@": "/src", }, - "/socket.io": { - target: process.env.REACT_APP_IO_URL ?? "http://localhost:9000", - ws: true, + }, + build: { + outDir: "./build", + }, + server: { + port: 3000, + host: true, + proxy: { + "/api": { + target: env.REACT_APP_BACK_URL ?? "http://localhost:9000", + rewrite: (path) => path.replace(/^\/api/, ""), + }, + "/socket.io": { + target: env.REACT_APP_IO_URL ?? "http://localhost:9000", + ws: true, + }, }, }, - }, + }; });