🚸 Skip validation if __ENV.js file does not exist
This commit is contained in:
5
packages/env/getRuntimeVariable.ts
vendored
5
packages/env/getRuntimeVariable.ts
vendored
@@ -2,10 +2,9 @@ declare const window: {
|
||||
__ENV?: any
|
||||
}
|
||||
|
||||
const isBrowser = () => Boolean(typeof window !== 'undefined' && window.__ENV)
|
||||
|
||||
export const getRuntimeVariable = (key: string) => {
|
||||
if (isBrowser()) return window.__ENV[key]
|
||||
if (typeof window !== 'undefined')
|
||||
return window.__ENV ? window.__ENV[key] : undefined
|
||||
if (typeof process === 'undefined') return undefined
|
||||
return process.env[key]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user