Appflow not using environment.prod.ts in Build Type : Release

Hi, I am using Appflow to build my Android package.
I notice that selecting the Build Type : Release , will not trigger the ‘production’ option under angular.json.
I need to have two env for firebase testing. Am I missing a step or should it be this way?

Angular.json

“configurations”: {
            “production”: {
              “fileReplacements”: [
                {
                  “replace”: “src/environments/environment.ts”,
                  “with”: “src/environments/environment.prod.ts”
                }
              ],
             …
            },
            “ci”: {
              “progress”: false
            }
          }
        },

Note, that I am on the Launch plan with Appflow.

1 Like

You may want to set up some environment variable using Appflow’s Automate->Environment
For example, set up a variable, $BUILD_ENV, assign it ‘production’, and refer to it in the package.json.

“scripts”: {
“ng”: “ng”,
“start”: “ng serve”,
"build": “BUILD_ENV=${BUILD_ENV:-local} ng build --configuration=$BUILD_ENV”,
“test”: “ng test”,
“lint”: “ng lint”,
“e2e”: “ng e2e”
},

If you don’t have access to the Automate->Environment, maybe all you need to do is set “build”: “production” in package.json

1 Like

Thank you for the very fast reply. Unfortunately it is hard for me to justify moving to the growth plan for this feature.

Looking over the build script I can now see that Appflow logs:
[12:14:46]: Successfully added Android platform
[12:14:46]: Building android…
[12:14:46]: $ cordova build android --release

Would changing the package.json script to
“build”: “ng build --prod”
affect the Appflow build command?

Changed the build script as suggested and now this shows in Appflow!

[13:04:06]: Build script detected…
[13:04:06]: $ npm run build
[13:04:06]: ▸ > ng build --configuration=‘production’

Thank you very much for the suggestion @Vigors

1 Like

You should build with ionic build android --release --prod

All the details should be in this quickstart

1 Like

@Vigors answer is correct.

"scripts": {
  ...
  "build": "BUILD_ENV=${BUILD_ENV:-local} ng build --configuration=$BUILD_ENV"
  ...
}

Complete details here.