Created
March 6, 2025 10:06
-
-
Save tomek-f/9b16daf8706821b83e2c0a951124f35c to your computer and use it in GitHub Desktop.
process.env.* on Vite app
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { loadEnv } from 'vite'; | |
import type { UserConfig } from 'vite'; | |
const config = ({ mode = 'development' }: UserConfig) => { | |
const env = loadEnv(mode, process.cwd(), 'MF'); | |
return { | |
define: Object.fromEntries( | |
Object.entries(env).map(([key, value]) => [`process.env.${key}`, JSON.stringify(value)]), | |
), | |
// other stuff here | |
} | |
} | |
export default config; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment