In this lesson, you will learn how to create distinct build profiles in your eas.json file to automate different configurations for development, staging, and production environments.
Why Customize Build Profiles?
When you build an app, your requirements change based on where the app is going. For example, your "Development" build might need extra debugging tools, while your "Production" build must be tightly optimized with a specific app store version. Instead of manually changing settings every time, EAS Build allows you to define these scenarios in a single file called eas.json.
Think of an eas.json profile as a "recipe" for your app. By defining multiple recipes, you can trigger a specific build with a single command, ensuring consistency across your team.
Setting Up Your Profiles
You define these profiles inside your eas.json file in the root of your project. Here is a simple example showing how to differentiate between a staging release and a final production release:
{
"build": {
"staging": {
"android": {
"buildType": "apk"
},
"env": {
"API_URL": "https://staging.api.example.com"
}
},
"production": {
"ios": {
"resourceClass": "m-medium"
},
"env": {
"API_URL": "https://api.example.com"
}
}
}
}
In this example, the staging profile is set up to generate an APK (great for internal testing), while the production profile requests a slightly more powerful cloud resource class for a faster build. We also inject different environment variables (like API_URL) automatically based on the profile chosen.
How to Use Them
Once these profiles are saved, you don't have to worry about the configuration details again. To run a specific profile, you simply add the --profile flag to your terminal command:
eas build --platform android --profile staging
This command tells Expo to look at the staging section of your configuration and apply those specific rules, saving you from manual mistakes and repetitive setup.
Key Takeaway: Build profiles act as reusable configuration recipes that allow you to manage environment-specific settings and build requirements automatically without manual intervention.