0👍
If you can use localStorage/Cookie to save a value in the browser, use the corresponding environment based on the value
example:
var config={}
if(localStorage.environment=="test")
config={env:'test'}
0👍
You can use localstorage or variables to save the env file. But I would recommend using webpack.
Sometimes it is practical to have different config values according to the environment that the application is running in.
As an example:
// config/prod.env.js
module.exports = {
NODE_ENV: '"production"',
DEBUG_MODE: false,
API_KEY: '"..."' // this is shared between all environments
}
// config/dev.env.js
module.exports = merge(prodEnv, {
NODE_ENV: '"development"',
DEBUG_MODE: true // this overrides the DEBUG_MODE value of prod.env
})
// config/test.env.js
module.exports = merge(devEnv, {
NODE_ENV: '"testing"'
})
For more detail you can access this Link
Source:stackexchange.com