Build with --prod flag on Ionic Pro


#1

I just migrated to Ionic Pro and configured all my app to work with it. All is working fine, but I don’t know how to generate an APK builded with --prod and --release flag.
On new dashboard I have only the option to choose release or debug method:

36

Before this I was running this command:

ionic package build android --prod --release --profile prod

This make the launch time fastest than only --release flag.

What I need to do to package my app with these tags?

Thank you!


#2

Good question, I think it was asked before in some thread about Ionic Pro.

As there seems to be no documentation on it yet (see https://ionic.zendesk.com/hc/en-us) I think you should contact support via the dashboard (bottom right has a button most of the time) or support form: http://ionicframework.com/support#support

Let us know if you get an answer.


#3

For now, I solve this issue using Android Studio.

I was having trouble with zipalign. I don’t know why that command doesn’t work. But Android Studio can generate an APK signed and zipaligned. So, I just need to run:

ionic cordova build android --prod --release

And use Android Studio to complete the task.

I’ll keep this topic open while I’m waiting the support answer.


Ionic Pro: Cli command ionic package not working in pro?
#4

Finally I got a way to solve this issue.

Ionic Pro makes a new build from your app based on your package.json build command.
To build apps using --prod flags, I had to include the flag on package.json.


#5

Huh what? :confused: What strange logic…

Can you show some code?
Did you get this confirmed from support that this is the only method?


#6

Yes, I confirmed that.

On package.json you have some scripts to run using npm.
When you upload your app to Ionic Pro (git push ionic master for example), the new dashboard will run npm run build based on your package.json scripts, so, you just need to change the command on package.json:

    "scripts": {
        "clean": "ionic-app-scripts clean",
        "build": "ionic-app-scripts build --prod",
        "ionic:build": "ionic-app-scripts build",
        "ionic:serve": "ionic-app-scripts serve"
    },

#7

Yeah but this breaks local execution of build (which might be even used by Ionic CLI?). Strange decision… But now we know it.

But great that you can finally build a production build with Ionic Pro. Baby steps :slight_smile:


#8

Doesn’t --prod also make sense on the ionic:build task? I’m curious why one and not the other.


#9

I want use --prod only when is “android” build, any tips?