When running an ionic build
I'm curious as to the difference between the --prod
and --release
flags?
The Ionic build docs state:
--prod Build the application for production
--release Create a Cordova release build
and while the Cordova CLI ref doesn't mention a --prod
flag, it states the following for --release
:
Perform a release build. This typically translates to release mode for the underlying platform being built.
Looking at the difference in the build output, building with --prod
seems to run an Ionic 'production' build, in that it also runs the ngc
and uglify
(which itself runs cleancss
) tasks.
And when I run a build with --release
, I seem to get a Cordova release build, which (per the docs) attempts to run a release build on whatever platform you're targeting.
Are those the only differences, or am I over-simplifying?
For reference, note the following output APK filesizes:
I'm using the latest (ATTOW) version of the Ionic Framework (3.9.2) and CLI (3.20.0).
ionic build will perform an Ionic build, which compiles web assets and prepares them for deployment. For Ionic/Cordova apps, the CLI will run cordova prepare , which copies the built web assets into the Cordova platforms that you've installed.
The –prod flag activates many optimization flags. One of them is –aot for Ahead Of Time compilation. Your component templates are compiled during the build, so TypeScript can detect more issues in your code.
1. ionic prepare copies all files from the www folder into the target platform's www folder. 2. ionic build also does this, but also builds the app's source code so that it can be run on a simulator/emulator or a device.
ionic build uses the Angular CLI. Use ng build --help to list all Angular CLI options for building your app.
Prod optimizes the code, Release makes it build in a different way so the app can be released to the stores. You have to use both for a fast version that can be released.
As Sujan12 says on this link.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With