2
0

🐛 Improve parse runtime env reading function

This commit is contained in:
Baptiste Arnaud
2023-08-28 14:19:40 +02:00
parent efd4600b7e
commit 036b407a11
8 changed files with 22 additions and 20 deletions

10
packages/env/getRuntimeVariable.ts vendored Normal file
View File

@@ -0,0 +1,10 @@
declare const window: {
__ENV?: any
}
const isBrowser = () => Boolean(typeof window !== 'undefined' && window.__ENV)
export const getRuntimeVariable = (key: string) => {
if (isBrowser()) return window.__ENV[key]
return process.env[key]
}