Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ionic build: difference between --prod and --release flags?

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:

  • Prod flag: 9.8 MB
  • Release flag: 11.7 MB
  • Prod + Release flags: 8.9 MB

I'm using the latest (ATTOW) version of the Ionic Framework (3.9.2) and CLI (3.20.0).

like image 496
Sensei James Avatar asked Mar 30 '18 20:03

Sensei James


People also ask

What does ionic build -- prod do?

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.

What does the prod flag do?

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.

What is the difference between ionic build and ionic prepare?

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.

Which of the below command is used to build an ionic app?

ionic build uses the Angular CLI. Use ng build --help to list all Angular CLI options for building your app.


1 Answers

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.

like image 135
Juan Carlos Alvez Balbastro Avatar answered Oct 04 '22 21:10

Juan Carlos Alvez Balbastro