I’ve been scouring the net trying to find some info on how to build and deploy an ionic 2 app as a PWA, but no luck. So I resort to posting here. If anyone could be so kind as to explain how to build and deploy a normal ionic 2 application (standard template is fine) to run as a PWA I’d be very grateful!
For what I can tell you make an Ionic 2 app (as PWA comes pre-set-up in an Ionic 2 App), build it using ionic serve --lab and then upload the files in the www folder to your web server. That’s what I did and it seems to work.
That’s probably not the proper way of doing it but like I say it worked for me.
Yeah, I’ve gotten that far. But as for what do to with the files I am a bit clueless. I also noticed that on my desktop browser I get a 404 because cordova.js is missing. Changing the path in the index.html solves this however, but I am not sure if this is the way to do it or if you’re expected to add more libraries?
@sebastianovide you can rewrite HTML on the fly (with PHP or so), and include expiry dates (for example the modification time of the file). Or just adjust the cache settings in your server, see http://www.mnot.net/cache_docs/ for instance.
Adding the browser platform gives you access to cordova functions and plugins that support the browser platform.
The support is certainly less than ios/android though so it’s not exactly the same, but ok for some functions.
Ok, thanks, I think I get it. So for my PWA, IF there is a browser implementation the plugin should work automatically. If not, I need to check what platform I am on and implement a web version of the plugin if needed…
I could also ignore the Browser platform completely and do the platform check and implementation for all of them.
Thanks. Maybe you would know this: I have a single code base for my native apps and now my new PWA. If I comment out the Service Worker in index.html in the source folder, will it affect my native app cordova build (I use Ionic Cloud to create the native packages). IE do I have to have 2 different Index.html files?