Install latest version of Angular CLI using this command:
# npm install -g @angular/cli
# npm install -g @angular/cli@latest
Create a new Angular project using CLI
# ng new Pwa-App
Check Application on Development server
# cd Pwa-App
# ng serve
Using above command, application will run with default view on: http://localhost:4200/
Build your PWA app, with following command:
# ng add @angular/pwa
If you got some versioning issues, please install another pwa version with following command:
# ng add @firstname.lastname@example.org
This command will do following steps:
1. It will enable the “serviceWorker” flag in “angular.json” file.
2. It will update your “package.json” file and add “@angular/service-worker” to it.
3. It will create “manifest.json” file under your “src” folder
4. It will include “manifest.json” to the “index.html” file.
5. It will create Angular service worker files “.ngsw-worker.js” and “.ngsw.json” in the production build.
6. It will add “ServiceWorkerModule” to “app.module.ts” and register it.
Create the production build using this command:
# ng build –prod