Ionic

Build Progressive Web App with Ionic 5

Share your learning

How to build a progressive web app with ionic 5? 

How to build an ionic PWA for sub-directory?

We are going to solve both the above problems. 

So, Let’s dive into it.

Build a Progressive Web app

If you want to learn and know more about the PWA concept first then  you can check ionic official docs.

Or, we have also written on progressive web apps here.

Because we are using angular with ionic, So, we can use the following angular package to build our PWA. Run the command to install the package.

ng add @angular/pwa 

After installing this package, we just need to run the following command.

ionic build --prod

And our www directory will be ready to use as progressive web app. We will simply deploy this directory on our server.

How to deploy ionic progressive web app to a sub-directory?

Building an ionic progressive web app is quite an easy task as shown above. But I was stuck when I tried to deploy this application in a subdirectory on the server.

After some digging, I found the solution. We need to run the following command to build progressive web app for a sub-directory.

ng build --prod --base-href=/sub-directory/

For example, you want to deploy your fitness PWA in a subdirectory /ionic/6/fitness, then run the following command.

ng build --prod --base-href=/ionic/6/fitness/

Go to manifest.webmanifest and replace the following urls.

scope : “./” to scope : “/”
start_url : “./”  to start_url : “/”

Now you can deploy your ionic 5 progressive web app on your server subdirectory.

Hope you enjoy the article.

See you in the next learning journey.

Satpal

Recent Posts

How to Switch PHP Versions in XAMPP Easily: Managing Multiple PHP Versions on Ubuntu

Today we are going to learn about managing multiple PHP versions on ubuntu with xampp.…

1 year ago

How to Use Coding to Improve Your Website’s SEO Ranking?

Let's understand about how to use coding to improve your website's SEO. In today’s computerized…

1 year ago

Most Important Linux Commands for Web Developers

Let's understand the most important linux commands for web developers. Linux, as an open-source and…

1 year ago

Top 75+ Laravel Interview Questions Asked by Top MNCs

Today we are going to discuss top 75+ Laravel interview questions asked by top MNCs.Laravel,…

1 year ago

Mailtrap Integration for Email Testing with Laravel 10

Today we will discuss about the Mailtrap integration with laravel 10 .Sending and receiving emails…

1 year ago

Firebase Cloud Messaging (FCM) with Ionic 6: Push Notifications

Today we are going to integrate FCM (Firebase Cloud Messaging) push notifications with ionic application.Firebase…

1 year ago