Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting homepage as a variable in package.json and make it change conditionally

How do I change/update homepage automatically without changing package.json in a React app?

I have A and B project, both projects have individual roots for Production Build, but they share a same root for Test Build. That's why I have different homepage configured for different environments. When I merge its Test Branch to its Prod Branch, I have to keep the package.json file different, which is not smart at all.

So, are there any ways that I can grab an Env variable and pass in?

like image 606
7537247 Avatar asked Nov 07 '22 10:11

7537247


1 Answers

if you are using create-react-app version greater or equal than 0.9.0 in package.json remove homepage and add PUBLIC_URL in your .env file

Adding Custom Environment Variables

like image 98
Julian Avatar answered Nov 15 '22 06:11

Julian