set env key

This commit is contained in:
andres alcocer
2022-02-08 19:29:59 -05:00
parent 4d7690888b
commit 28dae35a44

View File

@@ -8,18 +8,17 @@ var path = require('path')
module.exports = () => { module.exports = () => {
// call dotenv and it will return an Object with a parsed key // call dotenv and it will return an Object with a parsed key
console.log('PROCESS', process.env.NODE_ENV) let envKeys = {}
const env = dotenv.config().parsed if (process.env.NODE_ENV === 'production') {
// console.log('process------', process.env.API_KEY) envKeys = { API_KEY: process.env.API_KEY }
// console.log('env------', dotenv.config()) } else {
// reduce env variables to an oject
// reduce env variables to an oject const env = dotenv.config().parsed
const envKeys = Object.keys(env).reduce((prev, next) => { envKeys = Object.keys(env).reduce((prev, next) => {
prev[`process.env.${next}`] = JSON.stringify(env[next]) prev[`process.env.${next}`] = JSON.stringify(env[next])
return prev return prev
}, {}) }, {})
}
console.log('key', envKeys)
return { return {
entry: './src/index.js', entry: './src/index.js',