This is a currently a work in progress (hah)
- Add
pwa-manifest.jsontosrc/directory - Included in
.angular-cli.jsonfileassetsarray - Declared in
index.html
pwa-manifest.json will declare:
- icons to display for various sizes on mobile
- which page to load when launched from mobile desktop
- whether to display the mobile browser chrome
- Add
@angular/service-workertopackage.jsonand install withyarnornpm - Add
ngsw-manifest.jsonto app root directory - Add
"serviceWorker": truein.angular-cli.json ng build -prodwill now:- merge contents of
ngsw-manifest.jsonwith a file generated from contents ofdist/ - create
dist/worker-basic.min.jsfile - generate
dist/sw-register.<hash>.bundle.jsto register our service worker - include
dist/sw-register.<hash>.bundle.jsinindex.html
- merge contents of
Modern browsers will only allow you to install service workers on sites served over TLS.
To test the site locally over http you need to access the site via localhost or 127.0.0.1 otherwise browsers like
Firefox or Chrome will not register the service workers.
References:
- https://github.com/angular/mobile-toolkit/blob/master/guides/service-worker.md
- https://github.com/angular/mobile-toolkit/tree/master/service-worker/worker
- https://developer.mozilla.org/en-US/Apps/Progressive
- https://developers.google.com/web/progressive-web-apps/
- https://developer.mozilla.org/en-US/docs/Web/Manifest
Examples: