"Ionic upload" build package without prod flag?


I use ionic cordova build with (without) --prod flag to distinguish dev and prod environment.
It seems that “ionic upload” will only build and upload the package in dev mode, rather than prod mode.

This made all my packages, which were uploaded to ionic deploy service, truncated with prod configurations.

Anybody can tell why ionic deploy service does not use --prod ready package?


Upload normally takes whatever is in www from the last build and uploads it.

Do you see an additional build when you run ionic upload?

When run ‘ionic upload --deploy production’ , I see it triggers app-scripts first and do a dev build, then the uploading action is followed.

Is it different for you:hushed:?

as you can see, when ionic upload is called, a build dev is triggered

ionic upload --deploy=dev
[INFO] Running app-scripts build:

[09:55:59]  build dev started ...
[09:55:59]  clean started ...
[09:55:59]  clean finished in 1 ms

I found that --nobuild can disable the trigger.

ionic upload -NOTE “nobuild test” --deploy=production --nobuild

You can either use --nobuild or just add --prod to the upload command as well, right?

you are damn right… I feel like a bonehead o_O
it does accept --prod parameter.

1 Like

--prod is actually not one of the documented parameters:
I think this is because before it didn’t trigger a build. (Also why I had to ask and wasn’t sure about the additional build.)

I know it is not documented, I also realised it used to not trigger a build.
I blame myself for not even tried --prod in CMD in the first place and ended up spending so much time around it.

Now my configuration is like this:

  • . When I am testing new code locally: I push a dev build, which has this.deploy.checkupdate automatically disabled, to my phone. This ensures the new code will not be overwritten by Ionic cloud/deploy snapshot.
  • . When The new code is ready to ship: I run ionic upload --deploy production --prod. This will build a prod package, which has checkupdate automatically enabled, and push to ionic cloud for hot deployment.

Is this how you do it @Sujan12 too, or better solution?
p.s. Ionic really should have had an out-of-box dev/prod environment variable support

I never had automated applying of updates, only checking with a button. But what you are doing sounds reasonable.

I think this might be coming with Ionic Pro in the near future. The Deploy stuff will be streamlined a lot I think.

1 Like