Please provide the following:
- SDK Version: 41.0.0
- Platforms(Android/iOS/web/all): all
- Add the appropriate “Tag” based on what Expo library you have a question on.
Hi, I’m having trouble understanding the section Switching configuration based on the environment in order to publish the staging/prod app.config.js.
In the above paragraph, the app.config.js is using: export default ({ config }) => {
But in the later it use module.exports = () => {
I’m quite newbie in js so not exactly how to combine them into works, this is how I’m putting them at the moment, would it works if I try to do MY_ENVIRONMENT=production expo publish
?:
const stagingConfig = ({ config }) => {
const appConfig = {
...config,
version: 1,
// override anything you want
extra: {
API_URL: "my staging url",
AndroidGoogleServicesFile: "staging googleservice file",
// ...
},
}
return appConfig
}
const prodConfig = ({ config }) => {
const appConfig = {
...config,
version: 2,
// override anything you want
extra: {
API_URL: "my prod url",
AndroidGoogleServicesFile: "prod googleservice file",
// ...
},
}
return appConfig
}
module.exports = () => {
if (process.env.MY_ENVIRONMENT === "production") {
return prodConfig
} else {
return stagingConfig
}
}