1
0
Fork 0

client: register service worker

closes #296
This commit is contained in:
kontrollanten 2020-12-13 04:15:27 +01:00 committed by Chocobozzz
parent 26171379d0
commit dfdd158a75
3 changed files with 8 additions and 18 deletions

View File

@ -11,20 +11,9 @@ if (environment.production) {
const bootstrap = () => platformBrowserDynamic() const bootstrap = () => platformBrowserDynamic()
.bootstrapModule(AppModule) .bootstrapModule(AppModule)
.then(bootstrapModule => { .then(bootstrapModule => {
// TODO: Uncomment and remove unregistration when https://github.com/angular/angular/issues/21191 is fixed if ('serviceWorker' in navigator && environment.production) {
// TODO: Remove when https://github.com/angular/angular-cli/issues/8779 is fixed? navigator.serviceWorker.register('/ngsw-worker.js')
// if ('serviceWorker' in navigator && environment.production) { .catch(err => console.error('Cannot register service worker.', err))
// navigator.serviceWorker.register('/ngsw-worker.js')
// .catch(err => console.error('Cannot register service worker.', err))
// }
if (navigator.serviceWorker && typeof navigator.serviceWorker.getRegistrations === 'function') {
navigator.serviceWorker.getRegistrations()
.then(registrations => {
for (const registration of registrations) {
registration.unregister()
}
})
} }
if (!environment.production) { if (!environment.production) {

View File

@ -7,10 +7,9 @@
"resources": { "resources": {
"files": [ "files": [
"/index.html", "/index.html",
"/client/assets/images/favicon.png", "/client/assets/images/icons/favicon.png",
"/client/*.bundle.css", "/client/*.css",
"/client/*.bundle.js", "/client/*.js",
"/client/*.chunk.js",
"/manifest.webmanifest" "/manifest.webmanifest"
] ]
} }

View File

@ -70,6 +70,8 @@ else
npm run ng build -- --localize=false --output-path "dist/$defaultLanguage/" --deploy-url "/client/$defaultLanguage/" --prod --stats-json $additionalParams npm run ng build -- --localize=false --output-path "dist/$defaultLanguage/" --deploy-url "/client/$defaultLanguage/" --prod --stats-json $additionalParams
fi fi
mv "./dist/$defaultLanguage/ngsw-worker.js" "./dist/"
cd ../ && npm run build:embed && cd client/ cd ../ && npm run build:embed && cd client/
# Copy runtime locales # Copy runtime locales