Web

Angular 6 – How to Create PWA (Progressive Web App)

In this post, you will learn about steps that are required to create a progressive web app (PWA) with Angular 6. Unlike Angular 4 and Angular 5, it is very easy and quick with Angular 6. Just one command and you are done.

The following are the steps required to create PWA with Angular 6.

  • Create an angular app using the following command:
    ng new ProjectName
    
  • Go to the root folder, (ProjectName). Execute the following command:
    ng add  @angular/pwa
    

    The above command does some of the following:

    • Adds the @angular/service-worker package
    • Enables service worker to build support in the CLI. Imports and registers the service worker in the app module.
    • Creates the service worker configuration file called ngsw-config.json.
    • Updates the index.html with entries for manifest.json and meta-tags for the theme
    • With Angular 4 and 5, one required to manually create and install icon files. With above command, it is done automatically.
  • Build the project using the following command:
    ng build --prod
    
  • Time to test. Install http-server using the following command:
    npm i http-server
    
  • Go to dist folder and execute the following command:
    http-server -p 8080
    

Open the Chrome Browser and test the PWA aspect using Lighthouse plugin.

References

Summary

In this post, you learned about how to create progressive web app (PWA) using Angular 6.

Did you find this article useful? Do you have any questions or suggestions about this article? Leave a comment and ask your questions and I shall do my best to address your queries.

Ajitesh Kumar

I have been recently working in the area of Data analytics including Data Science and Machine Learning / Deep Learning. I am also passionate about different technologies including programming languages such as Java/JEE, Javascript, Python, R, Julia, etc, and technologies such as Blockchain, mobile computing, cloud-native technologies, application security, cloud computing platforms, big data, etc. For latest updates and blogs, follow us on Twitter. I would love to connect with you on Linkedin. Check out my latest book titled as First Principles Thinking: Building winning products using first principles thinking. Check out my other blog, Revive-n-Thrive.com

Share
Published by
Ajitesh Kumar

Recent Posts

Autoencoder vs Variational Autoencoder (VAE): Differences

Last updated: 08th May, 2024 In the world of generative AI models, autoencoders (AE) and…

22 hours ago

Linear Regression T-test: Formula, Example

Last updated: 7th May, 2024 Linear regression is a popular statistical method used to model…

2 days ago

Feature Engineering in Machine Learning: Python Examples

Last updated: 3rd May, 2024 Have you ever wondered why some machine learning models perform…

6 days ago

Feature Selection vs Feature Extraction: Machine Learning

Last updated: 2nd May, 2024 The success of machine learning models often depends on the…

7 days ago

Model Selection by Evaluating Bias & Variance: Example

When working on a machine learning project, one of the key challenges faced by data…

7 days ago

Bias-Variance Trade-off in Machine Learning: Examples

Last updated: 1st May, 2024 The bias-variance trade-off is a fundamental concept in machine learning…

1 week ago