]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/main.ts
Avoids easy cheating on vidoe views
[github/Chocobozzz/PeerTube.git] / client / src / main.ts
CommitLineData
b6827820
C
1import { enableProdMode } from '@angular/core'
2import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'
63c4db6d 3
b6827820
C
4import { AppModule } from './app/app.module'
5import { environment } from './environments/environment'
63c4db6d 6
77d07d69
C
7import { hmrBootstrap } from './hmr'
8
63c4db6d 9if (environment.production) {
b6827820 10 enableProdMode()
63c4db6d
C
11}
12
77d07d69 13const bootstrap = () => platformBrowserDynamic()
b6827820 14 .bootstrapModule(AppModule)
78967fca
C
15 .then(bootstrapModule => {
16 // TODO: Remove when https://github.com/angular/angular-cli/issues/8779 is fixed?
17 if ('serviceWorker' in navigator && environment.production) {
18 navigator.serviceWorker.register('/ngsw-worker.js')
19 .catch(err => console.error('Cannot register service worker.', err))
20 }
21
22 return bootstrapModule
23 })
24 .catch(err => {
25 console.error(err)
26 return null
27 })
77d07d69
C
28
29if (environment.hmr) {
30 if (module[ 'hot' ]) {
31 hmrBootstrap(module, bootstrap)
32 } else {
33 console.error('HMR is not enabled for webpack-dev-server!')
34 console.log('Are you using the --hmr flag for ng serve?')
35 }
36} else {
37 bootstrap()
38}