Change your app.json to base-app.json and untrack the original file in your .gitignore
cp app.json base-app.json
echo 'app.json' >> .gitignore
touch .env.example
touch .env
echo '.env' >> .gitignore
this generateConfig.js
use dotenv
package to extract from .env files. be sure to add it into your package.json.
example: yarn add dotenv --dev
or npm install dotenv --save-dev
best practice to remove app.json, then regenerate again. using something like https://github.com/isaacs/rimraf or just simple rm
- add into
package.json
's scripts:"generate-config": "rm app.json && node generateConfig"
- modify script start, to
npm generate-config && react-native-scripts start
{
...
"scripts": {
"start": "npm run generate-config && react-native-scripts start",
...
"generate-config": "rm app.json && node generateConfig"
},
...
*you can use something like https://github.com/mysticatea/npm-run-all to make it more smooth.