Register service worker
This commit is contained in:
parent
93df58cc48
commit
78967fca4c
|
@ -2,6 +2,10 @@
|
||||||
|
|
||||||
## v0.0.27-alpha
|
## v0.0.27-alpha
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* Add ability for admin to inject custom JavaScript/CSS
|
||||||
|
|
||||||
### Bug fixes
|
### Bug fixes
|
||||||
|
|
||||||
* Fix comment reply highlighting
|
* Fix comment reply highlighting
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
import { NgModule } from '@angular/core'
|
import { NgModule } from '@angular/core'
|
||||||
import { BrowserModule } from '@angular/platform-browser'
|
import { BrowserModule } from '@angular/platform-browser'
|
||||||
import { ServiceWorkerModule } from '@angular/service-worker'
|
|
||||||
import { AboutModule } from '@app/about'
|
import { AboutModule } from '@app/about'
|
||||||
import { ResetPasswordModule } from '@app/reset-password'
|
import { ResetPasswordModule } from '@app/reset-password'
|
||||||
|
|
||||||
import { MetaLoader, MetaModule, MetaStaticLoader, PageTitlePositioning } from '@ngx-meta/core'
|
import { MetaLoader, MetaModule, MetaStaticLoader, PageTitlePositioning } from '@ngx-meta/core'
|
||||||
import { environment } from '../environments/environment'
|
|
||||||
|
|
||||||
import { AccountModule } from './account'
|
import { AccountModule } from './account'
|
||||||
|
|
||||||
|
@ -60,9 +58,7 @@ export function metaFactory (): MetaLoader {
|
||||||
MetaModule.forRoot({
|
MetaModule.forRoot({
|
||||||
provide: MetaLoader,
|
provide: MetaLoader,
|
||||||
useFactory: (metaFactory)
|
useFactory: (metaFactory)
|
||||||
}),
|
})
|
||||||
|
|
||||||
ServiceWorkerModule.register('/ngsw-worker.js', { enabled: environment.production })
|
|
||||||
],
|
],
|
||||||
providers: [ ]
|
providers: [ ]
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { NgModule, Optional, SkipSelf } from '@angular/core'
|
|
||||||
import { CommonModule } from '@angular/common'
|
import { CommonModule } from '@angular/common'
|
||||||
import { RouterModule } from '@angular/router'
|
import { NgModule, Optional, SkipSelf } from '@angular/core'
|
||||||
import { BrowserAnimationsModule } from '@angular/platform-browser/animations'
|
import { BrowserAnimationsModule } from '@angular/platform-browser/animations'
|
||||||
|
import { RouterModule } from '@angular/router'
|
||||||
import { LoadingBarModule } from '@ngx-loading-bar/core'
|
import { LoadingBarModule } from '@ngx-loading-bar/core'
|
||||||
import { LoadingBarHttpClientModule } from '@ngx-loading-bar/http-client'
|
import { LoadingBarHttpClientModule } from '@ngx-loading-bar/http-client'
|
||||||
|
|
||||||
|
@ -9,10 +9,10 @@ import { SimpleNotificationsModule } from 'angular2-notifications'
|
||||||
import { ModalModule } from 'ngx-bootstrap/modal'
|
import { ModalModule } from 'ngx-bootstrap/modal'
|
||||||
|
|
||||||
import { AuthService } from './auth'
|
import { AuthService } from './auth'
|
||||||
import { LoginGuard, UserRightGuard } from './routing'
|
|
||||||
import { ServerService } from './server'
|
|
||||||
import { ConfirmComponent, ConfirmService } from './confirm'
|
import { ConfirmComponent, ConfirmService } from './confirm'
|
||||||
import { throwIfAlreadyLoaded } from './module-import-guard'
|
import { throwIfAlreadyLoaded } from './module-import-guard'
|
||||||
|
import { LoginGuard, UserRightGuard } from './routing'
|
||||||
|
import { ServerService } from './server'
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
imports: [
|
imports: [
|
||||||
|
|
|
@ -12,6 +12,19 @@ if (environment.production) {
|
||||||
|
|
||||||
const bootstrap = () => platformBrowserDynamic()
|
const bootstrap = () => platformBrowserDynamic()
|
||||||
.bootstrapModule(AppModule)
|
.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 (environment.hmr) {
|
||||||
if (module[ 'hot' ]) {
|
if (module[ 'hot' ]) {
|
||||||
|
|
|
@ -43,5 +43,5 @@
|
||||||
],
|
],
|
||||||
"name": "PeerTube",
|
"name": "PeerTube",
|
||||||
"short_name": "PeerTube",
|
"short_name": "PeerTube",
|
||||||
"start_url": "."
|
"start_url": "/videos/trending"
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,8 +11,6 @@ const clientsRouter = express.Router()
|
||||||
|
|
||||||
const distPath = join(root(), 'client', 'dist')
|
const distPath = join(root(), 'client', 'dist')
|
||||||
const assetsImagesPath = join(root(), 'client', 'dist', 'client', 'assets', 'images')
|
const assetsImagesPath = join(root(), 'client', 'dist', 'client', 'assets', 'images')
|
||||||
const manifestPath = join(root(), 'client', 'dist', 'manifest.json')
|
|
||||||
const serviceWorkerPath = join(root(), 'client', 'dist', 'ngsw-worker.js')
|
|
||||||
const embedPath = join(distPath, 'standalone', 'videos', 'embed.html')
|
const embedPath = join(distPath, 'standalone', 'videos', 'embed.html')
|
||||||
const indexPath = join(distPath, 'index.html')
|
const indexPath = join(distPath, 'index.html')
|
||||||
|
|
||||||
|
@ -27,8 +25,17 @@ clientsRouter.use('/videos/embed', (req: express.Request, res: express.Response,
|
||||||
})
|
})
|
||||||
|
|
||||||
// Static HTML/CSS/JS client files
|
// Static HTML/CSS/JS client files
|
||||||
clientsRouter.use('/manifest.json', express.static(manifestPath, { maxAge: STATIC_MAX_AGE }))
|
|
||||||
clientsRouter.use('/ngsw-worker.js', express.static(serviceWorkerPath, { maxAge: STATIC_MAX_AGE }))
|
const staticClientFiles = [
|
||||||
|
'manifest.json',
|
||||||
|
'ngsw-worker.js',
|
||||||
|
'ngsw.json'
|
||||||
|
]
|
||||||
|
for (const staticClientFile of staticClientFiles) {
|
||||||
|
const path = join(root(), 'client', 'dist', staticClientFile)
|
||||||
|
clientsRouter.use('/' + staticClientFile, express.static(path, { maxAge: STATIC_MAX_AGE }))
|
||||||
|
}
|
||||||
|
|
||||||
clientsRouter.use('/client', express.static(distPath, { maxAge: STATIC_MAX_AGE }))
|
clientsRouter.use('/client', express.static(distPath, { maxAge: STATIC_MAX_AGE }))
|
||||||
clientsRouter.use('/client/assets/images', express.static(assetsImagesPath, { maxAge: STATIC_MAX_AGE }))
|
clientsRouter.use('/client/assets/images', express.static(assetsImagesPath, { maxAge: STATIC_MAX_AGE }))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue