Steps:
- Rename your
app.json
file tobase-app.json
. This will be used as the template to generate the finalapp.json
output. - On your
.gitignore
file, add:
# ...your other ignored files
# use base-app.json instead because we're generating this file during builds.
app.json
- On your
package.json
file, modify your scripts so thatcreate-react-native-app-config
is executed beforereact-native-scripts
:
"scripts": {
"start": "npm run create-react-native-app-config && react-native-scripts start",
"eject": "react-native-scripts eject",
"android": "npm run create-react-native-app-config && react-native-scripts android",
"ios": "npm run create-react-native-app-config && react-native-scripts ios",
"test": "npm run create-react-native-app-config && jest",
"create-react-native-app-config": "rimraf app.json && node create-react-native-app-config.js"
},
- Copy
create-react-native-app-config.js
below into a file at the root level of your project.
my-react-native-app-project
|
├── ...other files
|
├── .babelrc
├── .gitignore
├── .watchmanconfig
├── package.json
├── app.json
├── App.test.js
├── App.js
├── create-react-native-app-config.js <---- create this file, then paste the code below into it!
|
└── ...other files