🐛 Improve parse runtime env reading function
This commit is contained in:
10
packages/env/getRuntimeVariable.ts
vendored
Normal file
10
packages/env/getRuntimeVariable.ts
vendored
Normal 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]
|
||||
}
|
||||
Reference in New Issue
Block a user