aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorkontrollanten <6680299+kontrollanten@users.noreply.github.com>2020-12-13 04:15:27 +0100
committerChocobozzz <chocobozzz@cpy.re>2021-01-13 09:10:52 +0100
commitdfdd158a75d91208a8444a8bad1663ca3bafe299 (patch)
treec53f392aebdb405a6e9cb9e13dd8560999a3e67c
parent26171379d0196ac645923e72b12e1cf29089835b (diff)
downloadPeerTube-dfdd158a75d91208a8444a8bad1663ca3bafe299.tar.gz
PeerTube-dfdd158a75d91208a8444a8bad1663ca3bafe299.tar.zst
PeerTube-dfdd158a75d91208a8444a8bad1663ca3bafe299.zip
client: register service worker
closes #296
-rw-r--r--client/src/main.ts17
-rw-r--r--client/src/ngsw-config.json7
-rwxr-xr-xscripts/build/client.sh2
3 files changed, 8 insertions, 18 deletions
diff --git a/client/src/main.ts b/client/src/main.ts
index 0fddf3aac..99976a3f7 100644
--- a/client/src/main.ts
+++ b/client/src/main.ts
@@ -11,20 +11,9 @@ if (environment.production) {
11const bootstrap = () => platformBrowserDynamic() 11const bootstrap = () => platformBrowserDynamic()
12 .bootstrapModule(AppModule) 12 .bootstrapModule(AppModule)
13 .then(bootstrapModule => { 13 .then(bootstrapModule => {
14 // TODO: Uncomment and remove unregistration when https://github.com/angular/angular/issues/21191 is fixed 14 if ('serviceWorker' in navigator && environment.production) {
15 // TODO: Remove when https://github.com/angular/angular-cli/issues/8779 is fixed? 15 navigator.serviceWorker.register('/ngsw-worker.js')
16 // if ('serviceWorker' in navigator && environment.production) { 16 .catch(err => console.error('Cannot register service worker.', err))
17 // navigator.serviceWorker.register('/ngsw-worker.js')
18 // .catch(err => console.error('Cannot register service worker.', err))
19 // }
20
21 if (navigator.serviceWorker && typeof navigator.serviceWorker.getRegistrations === 'function') {
22 navigator.serviceWorker.getRegistrations()
23 .then(registrations => {
24 for (const registration of registrations) {
25 registration.unregister()
26 }
27 })
28 } 17 }
29 18
30 if (!environment.production) { 19 if (!environment.production) {
diff --git a/client/src/ngsw-config.json b/client/src/ngsw-config.json
index b5d11e59a..d68db79d0 100644
--- a/client/src/ngsw-config.json
+++ b/client/src/ngsw-config.json
@@ -7,10 +7,9 @@
7 "resources": { 7 "resources": {
8 "files": [ 8 "files": [
9 "/index.html", 9 "/index.html",
10 "/client/assets/images/favicon.png", 10 "/client/assets/images/icons/favicon.png",
11 "/client/*.bundle.css", 11 "/client/*.css",
12 "/client/*.bundle.js", 12 "/client/*.js",
13 "/client/*.chunk.js",
14 "/manifest.webmanifest" 13 "/manifest.webmanifest"
15 ] 14 ]
16 } 15 }
diff --git a/scripts/build/client.sh b/scripts/build/client.sh
index 0f5b2d976..68939290c 100755
--- a/scripts/build/client.sh
+++ b/scripts/build/client.sh
@@ -70,6 +70,8 @@ else
70 npm run ng build -- --localize=false --output-path "dist/$defaultLanguage/" --deploy-url "/client/$defaultLanguage/" --prod --stats-json $additionalParams 70 npm run ng build -- --localize=false --output-path "dist/$defaultLanguage/" --deploy-url "/client/$defaultLanguage/" --prod --stats-json $additionalParams
71fi 71fi
72 72
73mv "./dist/$defaultLanguage/ngsw-worker.js" "./dist/"
74
73cd ../ && npm run build:embed && cd client/ 75cd ../ && npm run build:embed && cd client/
74 76
75# Copy runtime locales 77# Copy runtime locales