Ionic cordova build android with packageType and pass arguments to cordova hook

1.6k views Asked by At

I am on Windows OS

I have a before_build Cordova hook. Inside the hook I pass arguments like this:

ionic cordova build android --release --configuration=ivd -- -- --ivd

The ivd argument is passed to the context.opts.options. This works fine.

I want to build my application with packageType=bundle.

I have seen in several posts that the way to do that is this:

ionic cordova build android --release -- -- -- --packageType=bundle

This works fine and my application builds in .aab format

PROBLEM

If I want to combine the two (build application in bundle mode AND pass arguments to cordova hook) it is not working

TRIED

ionic cordova build android --release -- --ivd -- -- --packageType=bundle
ionic cordova build android --release -- --ivd -- -- -- --packageType=bundle

and several other combinations

WHAT WORKS

If I do only cordova like this:

cordova build android --release --ivd -- -- --packageType=bundle

I get the desired output

EDIT

I answered my question but I would love a deep explanation of how the '--' works when running ionic cordova and want to combine a cordova hook

1

There are 1 answers

0
Iraklis Bekiaris On

This worked on Windows

ionic cordova build android --release --configuration=ivd -- -- --ivd -- --packageType=bundle

This worked on Linux

ionic cordova build android --release --configuration=ivd -- --ivd -- --packageType=bundle