Reputation: 123
I'd like to use a config file in a react/redux app. In this thread
How to store Configuration file and read it using React
i found a nice solution but i receive the following error when using require in my redux action file.
Module not found: Error: Cannot resolve module 'Config'
Upvotes: 2
Views: 1403
Reputation: 123
I managed to solve it with the following webpack config:
plugins:[
new webpack.DefinePlugin({
'process.env':{
'NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'development')
}
}),
],
externals: {
'Config': JSON.stringify(process.env.NODE_ENV === 'production' ? {
api: "http://www.vitto.mt.it/eventi/api/public/"
} : {
api: "/react/eventi/api/public/"
})
},
and calling it:
var Config = require('Config');
But i still have to set manually the NODE_ENV value. How can i set it using an external file?
Upvotes: 2