1

Is it possible to give parameters using .config file to reactApp after running npm run build I am fetching data thorugh a url in reactApp. I need to deploy only the built file.

After giving npm run build, can't I change the values through config file like in Java. Or else re-building the app is the only solution?

Vithursa Mahendrarajah
  • 1,194
  • 2
  • 15
  • 28

1 Answers1

0

process.env.SOME_VARIABLE is used to provide an environment variable. You can initialize this variable with build app command. Check more on create-react-app repo docs

mhnpd
  • 381
  • 2
  • 11
  • I am asking for parameters to be used within .js files. Not for environment variables. – Vithursa Mahendrarajah Apr 11 '18 at 06:16
  • 1
    When you build a react app process.env.NODE_ENV has value "production" and in development, it has value 'development' (automatic set by create-react-app) when you export a config file you can check its production/developm ent and export a file as per need. I don't know a better way to inject different config in production. – mhnpd Apr 11 '18 at 07:26