How-to: Use different environment variables for production and development with ionic 3

Create 2 configuration files with environment variables in folder src/config: config.dev.ts and config.prod.ts


Update: For Ionic < 3.7

Override 2 configuration files provided by @ionic/app-scripts package: optimization.config.js and webpack.config.js

Notify ionic to use these overridden files by adding links to them to package.json


Update: For Ionic >= 3.7

Override webpack.config.js, provided by @ionic/app-scripts package.

Notify ionic to use overridden file by adding link to package.json


Instruct TypeScript to use custom alias for a module by editing tsconfig.json

Finally, use your environment variables

Automatically build Android APK for Ionic 3 project stored in GitLab

Setup GitLab CI. Your configuration file will look something like this

Optionally put a link to file in your README.md that will look like

https://gitlab.com/YOUR_ORGANIZATION_NAME/YOUR_PROJECT_NAME/builds/artifacts/master/raw/platforms/android/build/outputs/apk/android-debug.apk?job=build_android