fix: make URL environment variable work during build

This commit is contained in:
Twirre Meulenbelt
2026-02-09 16:44:01 +01:00
parent 8fa2adc973
commit 3a347f0716

View File

@@ -1,15 +1,21 @@
import { defineConfig } from 'vite' import { defineConfig, loadEnv } from 'vite'
import react from '@vitejs/plugin-react' import react from '@vitejs/plugin-react'
// https://vite.dev/config/ // https://vite.dev/config/
export default defineConfig({ export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd(), "");
return {
plugins: [react()], plugins: [react()],
define: { define: {
__VITE_API_BASE_URL__: "import.meta.env.VITE_API_BASE_URL", __VITE_API_BASE_URL__: env.VITE_API_BASE_URL
? JSON.stringify(env.VITE_API_BASE_URL)
: "undefined",
}, },
css: { css: {
modules: { modules: {
localsConvention: "camelCase", localsConvention: "camelCase",
} }
}, },
};
}) })