We deploy our ionic5 app to both web and ios. For web, we deploy in a folder, so our angular.json has baseHref/deployUrl set. We notice that, we have to remove those options from angular.json when building with “ionic capacitor run ios” or it doesn’t work. Is there anyway to support both scenarios without having to constantly edit angular.json depending on what you are doing?
The way I handle this is to offload the work to the httpd. I use nginx for this, so consult your preferred server’s documentation if you don’t. For nginx, setting the root
in the relevant server
block to /usr/share/nginx/html/foo
should act equivalently to setting baseHref
to /foo/
and serving out of a root
of /usr/share/nginx/html
.
Actually, i finally figured out the correct command line parameters. If I remove the stuff from angular.json and build the web app with “ng build --base-href /myapp/ --deploy-url /myapp/” instead of just “ionic build” everything will work like I want. Hopefully somebody will update the documentation to better cover this case.
Well, I guess if you’re happy with that, it doesn’t matter what I think, but it sounds like a step backwards to me, because now you’ve taken crucial information needed to build the app in a usable state out of anywhere that it can be documented and made it reliant on whoever (or whatever) is building the app knowing the proper magical incantation.
You’ve also nerfed out any possibility of taking advantage of additional functionality that the ionic
CLI may attempt to add above and beyond that of underlying Angular CLI.