You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

18 lines
526 B

import dotenv from 'dotenv'
dotenv.config({ path: `.env.${process.env.NODE_ENV}` })
const ENV_PREFIX = 'NUXT_'
export const getEnvConfig = () => {
const config: Record<string, any> = {}
Object.keys(process.env).forEach((evnKey) => {
if (evnKey.includes(ENV_PREFIX)) {
const key = evnKey
.replace(ENV_PREFIX, '')
.toLowerCase()
.replace(/\_([A-Za-z])/g, function (all, $1) {
return $1.toUpperCase()
})
config[key] = process.env[evnKey]
}
})
return config
}