PWA — Progressive Web App comes default with Ionic can be hosted on Google Firebase

Progressive Web App

Ionic Framework helps you reuse your app codebase to generate a working PWA and host it on Google Firebase Hosting — here is the developer’s solution.

Every Ionic app comes with an index.html file — That contains the below commented javascript code:

<! — un-comment this code to enable service worker
<script>
if (‘serviceWorker’ in navigator) {
navigator.serviceWorker.register(‘service-worker.js’)
.then(() => console.log(‘service worker installed’))
.catch(err => console.log(‘Error’, err));
}
</script>

Service worker works only on HTTPS connections development can be done on localhost. They can be attacked on a non secure connection.

Uncomment above code and build your app for production with below command, while inside your app folder:

ionic build --prod

Before you run the production build command check if your index.html page has below script included:

<link rel=”manifest” href=”manifest.json”>

Running the production build will compile he files to the most reduced size minified scripts etc and all you have to do is setup your Firebase Hosting — checkout my story on Google Firebase Hosting and initialise a Firebase deploy command with your app’s /www folder files.

If you like this quick solution share this knowledge with your fellow developers.