]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/main.ts
client: register service worker
[github/Chocobozzz/PeerTube.git] / client / src / main.ts
CommitLineData
68f6c87a
C
1import { ApplicationRef, enableProdMode } from '@angular/core'
2import { enableDebugTools } from '@angular/platform-browser'
b6827820 3import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'
b6827820
C
4import { AppModule } from './app/app.module'
5import { environment } from './environments/environment'
63c4db6d
C
6
7if (environment.production) {
b6827820 8 enableProdMode()
63c4db6d
C
9}
10
77d07d69 11const bootstrap = () => platformBrowserDynamic()
361dcebc 12 .bootstrapModule(AppModule)
78967fca 13 .then(bootstrapModule => {
dfdd158a 14 if ('serviceWorker' in navigator && environment.production) {
15 navigator.serviceWorker.register('/ngsw-worker.js')
16 .catch(err => console.error('Cannot register service worker.', err))
73e09f27 17 }
78967fca 18
68f6c87a
C
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
78967fca
C
27 return bootstrapModule
28 })
29 .catch(err => {
30 console.error(err)
31 return null
32 })
77d07d69 33
4f926722 34bootstrap()