Aditya Chandrayan Aditya Chandrayan - 4 months ago 15
Node.js Question

Export in react js based on a condition?

I have two loggers but i am facing a problem.
i want something similar to this.
HOwever if i use only one logger without the if case then it works fine.

if(process.env.NODE_ENV === 'DEVELOPMENT')
{
export default logger_dev;
}
if(process.env.NODE_ENV === 'PRODUCTION')
{
export default logger_prod;
}

Answer
const logger = process.env.NODE_ENV === 'PRODUCTION' ? logger_prod : logger_dev;
export default logger;