]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/main.ts
client: register service worker
[github/Chocobozzz/PeerTube.git] / client / src / main.ts
1 import { ApplicationRef, enableProdMode } from '@angular/core'
2 import { enableDebugTools } from '@angular/platform-browser'
3 import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'
4 import { AppModule } from './app/app.module'
5 import { environment } from './environments/environment'
6
7 if (environment.production) {
8 enableProdMode()
9 }
10
11 const bootstrap = () => platformBrowserDynamic()
12 .bootstrapModule(AppModule)
13 .then(bootstrapModule => {
14 if ('serviceWorker' in navigator && environment.production) {
15 navigator.serviceWorker.register('/ngsw-worker.js')
16 .catch(err => console.error('Cannot register service worker.', err))
17 }
18
19 if (!environment.production) {
20 const applicationRef = bootstrapModule.injector.get(ApplicationRef)
21 const componentRef = applicationRef.components[0]
22
23 // allows to run `ng.profiler.timeChangeDetection();`
24 enableDebugTools(componentRef)
25 }
26
27 return bootstrapModule
28 })
29 .catch(err => {
30 console.error(err)
31 return null
32 })
33
34 bootstrap()