import { defineConfig, loadEnv } from 'vite'; import react from '@vitejs/plugin-react'; export default defineConfig(({ mode }) => { // Load env file based on `mode` in the current working directory. const env = loadEnv(mode, (process as any).cwd(), ''); return { plugins: [react()], define: { // This allows the app code to continue using process.env.API_KEY // even though it is running in the browser. 'process.env.API_KEY': JSON.stringify(env.API_KEY) } }; });