From 78967fca4cacbc247fa6fb62d64b2d6825a10804 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 22 Feb 2018 14:15:23 +0100 Subject: Register service worker --- client/src/main.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'client/src/main.ts') diff --git a/client/src/main.ts b/client/src/main.ts index b02b6830f..9686ba4b8 100644 --- a/client/src/main.ts +++ b/client/src/main.ts @@ -12,6 +12,19 @@ if (environment.production) { const bootstrap = () => platformBrowserDynamic() .bootstrapModule(AppModule) + .then(bootstrapModule => { + // TODO: Remove when https://github.com/angular/angular-cli/issues/8779 is fixed? + if ('serviceWorker' in navigator && environment.production) { + navigator.serviceWorker.register('/ngsw-worker.js') + .catch(err => console.error('Cannot register service worker.', err)) + } + + return bootstrapModule + }) + .catch(err => { + console.error(err) + return null + }) if (environment.hmr) { if (module[ 'hot' ]) { -- cgit v1.2.3