I have some configuration keys like below:
/config
/db
/dev.js
/index.js
/prod.js
I import keys like this:
import dbConfig from './config/db'
But in index.js
, I use CommonJS syntax to export module conditionally. Is it possible to do it with ES6? If yes, how?
module.exports = process.env.NODE_ENV === 'production'
? require('./prod')
: require('./dev');
I am using webpack ^4.6.0
. Tried my luck with babel-plugin-dynamic-import-webpack
but it didn't work.
I may not aware of some best practices or plugins that I can use, so I'd appreciate your thoughts.