Ionic Services - Package/Cloud build does not respect the --prod flag

Aha!

Does ionic package build at all? Or does it just take the content of /www and some other files (like config.xml) that it needs, uploads them and then only builds the Cordova stuff on the server? Would totally make sense…

Output is rather minimal at “Preparing your resources…” and “Uploading your project to Ionic…” then done. I noted that the /www/index.html was changed when running ionic package but nothing else in /www.

I guess the issue is actually not in the app scripts, but probably in the CLI tool not calling build when using package (potentially on purpose I guess).

You should open a Issue on GitHub for that kind of problem.

Is this really a problem or issue? Didn’t we just misundersand how “ionic package” (in the v2 CLI) worked?

PS C:\Users\Jan> ionic help package
  _             _
 (_)           (_)
  _  ___  _ __  _  ___
 | |/ _ \| '_ \| |/ __|
 | | (_) | | | | | (__
 |_|\___/|_| |_|_|\___|  CLI v2.2.2

=======================



package <command> [options] ...................  Use Ionic Package to build your app
                                                 <command> build android, build ios, list, info, or download
        [--release]  ..........................  (build <platform>) Mark this build as a release

        [--profile|-p <tag>]  .................  (build <platform>) Specify the Security Profile to use with this build

        [--noresources]  ......................  (build <platform>) Do not generate icon and splash screen resources during this build

        [--destination|-d <path>]  ............  (download) Specify the destination directory to download your packaged app.

I think everybody just wrongly assumed that ionic package works the same as ionic build.

The Ionic core team have confirmed via email that this is indeed an intermittent issue affecting some users but not all:

I’ve talked this over with some of our developers, and we’ve got this filed as a bug to investigate. I’ll let you know when we have any updates on that.

It doesn’t look like this is affecting all users. I’ve been interacting with several users just today who are doing release builds through Package just fine.

For the time being, it looks like this is working for you some of the time, or am I misunderstanding? Also, are you able to build locally, not using Package? That might be your best bet for now.

The truth is, we’re aware that Package in its current state has some pretty serious stability issues, and it’s undergoing a serious overhaul as we speak.

You’ll be hearing from me again when we have any updates on this issue. I wouldn’t expect an immediate fix, unfortunately, so you might also want to start looking into workarounds or alternate solutions.

Yes, I had a similar theory - I delete the WWW folder, then run in --prod mode before I do an upload it works SOME of the time. I can’t do local prod IOS builds as I don’t have a MAC (Which is why I use the cloud service)

Actually, you were right - this worked for me. Process:

  1. Delete WWW folder
  2. Run “ionic serve --prod”
  3. Run “ionic package build android --prod --release --profile prod”

Result = 6.4meg APK file

  1. Delete WWW folder
  2. Run “ionic serve --prod”
  3. Run “ionic build browser --prod”
  4. Run “ionic package build android --prod --release --profile prod”

Result = 5.1meg APK file!

I’m glad it’s working consistently for you now. There should be no need for manually deleting www and running ionic serve. --prod does nothing for ionic serve (and seems like it won’t ever).

For step 3, “npm run build --prod” is a little bit quicker.

Btw, a fix for this has been done for v3 of the cli.

So do keep the “–prod” on your package command line, but when you upgrade to v3 cli then you can skip the workaround of Step 3. (but if you didn’t include --prod on the package command line, then upgraded it would build a prod build then a non prod build)

1 Like

Hmm, so is there still a problem?
Does ionic serve --prod create a different output than ionic build browser --prod? Is this expected?
Can you do the second run again, but without ionic serve --prod at all?