Skip to content →

Deploy Ionic PWA to a sub-path

I often don’t bother about deploying temporary apps on their own realm like host. e.g. newapp.brayan.com. I rather chose to deploy them to a sub-path. e.g. www.brayan.com/newapp.

If your main site is already set up, it does NOT require any cumbersome URL rewriting. Work with the base-url and have Angular, not Ionic, adapt the references to javascripts and other web resources.

The only drawback that comes along is that Ionic CLI  has NOT implemented the argument –base-href so far.  Anyhow, you are not missing anything if you are invoking the ng build instead.

ng build --prod --base-href=/newapp/

The only scenario, I could think of, where that could hamper your deployment process, is when you develop with Ionic without using Angular. That is with Stencil (without Angular) for example.

Published in DevOps

2 Comments

  1. Gabor Kis Gabor Kis

    Thanks Brayan, this helped me a lot. What is weird, that now when I create an app on iPhone via “Add Home Screen” and start the app, on the top shows the url and a Done button. Have you had this experience ?
    Thanks

    • brayan@brayan.com brayan@brayan.com

      Hi Gabor. I assume you are speaking about a PWA, for which you need to compile with –service-worker option. Without that it wont build a PWA client. If done so, you should not see an URL, wenn you select it to add the home screen. I just checked on an iPhone X with the latest updates.

Leave a Reply

Your email address will not be published. Required fields are marked *