From 3a347f0716b45813c0aec8d2b2479ef977115f9e Mon Sep 17 00:00:00 2001 From: Twirre Meulenbelt <43213592+TwirreM@users.noreply.github.com> Date: Mon, 9 Feb 2026 16:44:01 +0100 Subject: [PATCH] fix: make URL environment variable work during build --- vite.config.ts | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/vite.config.ts b/vite.config.ts index b21d76a..3596a79 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -1,15 +1,21 @@ -import { defineConfig } from 'vite' +import { defineConfig, loadEnv } from 'vite' import react from '@vitejs/plugin-react' // https://vite.dev/config/ -export default defineConfig({ - plugins: [react()], - define: { - __VITE_API_BASE_URL__: "import.meta.env.VITE_API_BASE_URL", - }, - css: { - modules: { - localsConvention: "camelCase", - } - }, +export default defineConfig(({ mode }) => { + const env = loadEnv(mode, process.cwd(), ""); + + return { + plugins: [react()], + define: { + __VITE_API_BASE_URL__: env.VITE_API_BASE_URL + ? JSON.stringify(env.VITE_API_BASE_URL) + : "undefined", + }, + css: { + modules: { + localsConvention: "camelCase", + } + }, + }; })