From 027dc3a01f7284238268691145768f9129b3ae27 Mon Sep 17 00:00:00 2001 From: moon Date: Fri, 11 Oct 2024 03:13:28 -0700 Subject: [PATCH] fix config --- vite.config.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/vite.config.ts b/vite.config.ts index aa08414..3f0f20e 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -2,11 +2,18 @@ import react from '@vitejs/plugin-react' import { defineConfig, loadEnv } from 'vite' export default ({ mode }) => { - // Load app-level env vars to node-level env vars. - process.env = { ...process.env, ...loadEnv(mode, process.cwd()) } + // Load environment variables and expose them as Vite environment variables + const env = loadEnv(mode, process.cwd()) return defineConfig({ base: '/RubyLive/', plugins: [react()], + define: { + // Explicitly define the variables you want to inject into the build + 'process.env': process.env, // This ensures Node-level env vars are accessible if needed + 'import.meta.env.VITE_OPENAI_API_KEY': JSON.stringify(env.VITE_OPENAI_API_KEY), + 'import.meta.env.VITE_SIMLI_API_KEY': JSON.stringify(env.VITE_SIMLI_API_KEY), + 'import.meta.env.VITE_ELEVENLABS_API_KEY': JSON.stringify(env.VITE_ELEVENLABS_API_KEY), + }, }) }