From 28dae35a44a82ee64b2556e59f2922a23ad54c5a Mon Sep 17 00:00:00 2001 From: andres alcocer Date: Tue, 8 Feb 2022 19:29:59 -0500 Subject: [PATCH] set env key --- webpack.config.js | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/webpack.config.js b/webpack.config.js index 45a3403..17f57a9 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -8,18 +8,17 @@ var path = require('path') module.exports = () => { // call dotenv and it will return an Object with a parsed key - console.log('PROCESS', process.env.NODE_ENV) - const env = dotenv.config().parsed - // console.log('process------', process.env.API_KEY) - // console.log('env------', dotenv.config()) - - // reduce env variables to an oject - const envKeys = Object.keys(env).reduce((prev, next) => { - prev[`process.env.${next}`] = JSON.stringify(env[next]) - return prev - }, {}) - - console.log('key', envKeys) + let envKeys = {} + if (process.env.NODE_ENV === 'production') { + envKeys = { API_KEY: process.env.API_KEY } + } else { + // reduce env variables to an oject + const env = dotenv.config().parsed + envKeys = Object.keys(env).reduce((prev, next) => { + prev[`process.env.${next}`] = JSON.stringify(env[next]) + return prev + }, {}) + } return { entry: './src/index.js',