gogoWebsite

React Configuring Global Variables

Updated to 7 hours ago

React Configuring Global Variables

With webpack, you can place an env specific configuration in the externals field

externals: {
  'Config': JSON.stringify(process.env.ENV === 'production' ? {
    serverUrl: ""
  } : {
    serverUrl: "http://localhost:8090"
  })
}

Then in your module you can use config:

var Config = require(‘Config’)
fetchData( + ‘/Enterprises/…’)