Add Service Work(e|a)r(round)

uses the promise in returned by .bootstrapModule
to register the serviceworker if required.
Seems to work reliable, even in unstable environments.
Requires production mode to comprehend.
(at least ng build --prod)
This commit is contained in:
Sean Engelhardt 2019-03-05 14:06:36 +01:00
parent 4349f2eb11
commit 3e4dffd7a4

View File

@ -10,4 +10,9 @@ if (environment.production) {
platformBrowserDynamic()
.bootstrapModule(AppModule)
.then(() => {
if ('serviceWorker' in navigator && environment.production) {
navigator.serviceWorker.register('ngsw-worker.js');
}
})
.catch(err => console.log(err));