]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/commitdiff
client: register service worker
authorkontrollanten <6680299+kontrollanten@users.noreply.github.com>
Sun, 13 Dec 2020 03:15:27 +0000 (04:15 +0100)
committerChocobozzz <chocobozzz@cpy.re>
Wed, 13 Jan 2021 08:10:52 +0000 (09:10 +0100)
closes #296

client/src/main.ts
client/src/ngsw-config.json
scripts/build/client.sh

index 0fddf3aace64c3d7938a4b25b1adfb7c01288806..99976a3f71673cfec908da725db77c9c1f0f6a27 100644 (file)
@@ -11,20 +11,9 @@ if (environment.production) {
 const bootstrap = () => platformBrowserDynamic()
   .bootstrapModule(AppModule)
   .then(bootstrapModule => {
-    // TODO: Uncomment and remove unregistration when https://github.com/angular/angular/issues/21191 is fixed
-    // 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))
-    // }
-
-    if (navigator.serviceWorker && typeof navigator.serviceWorker.getRegistrations === 'function') {
-      navigator.serviceWorker.getRegistrations()
-               .then(registrations => {
-                 for (const registration of registrations) {
-                   registration.unregister()
-                 }
-               })
+    if ('serviceWorker' in navigator && environment.production) {
+      navigator.serviceWorker.register('/ngsw-worker.js')
+        .catch(err => console.error('Cannot register service worker.', err))
     }
 
     if (!environment.production) {
index b5d11e59af94f5e6cf8ee5f001024b9bcf43f87f..d68db79d019e515e416b53c0661dbf301d29c2b8 100644 (file)
@@ -7,10 +7,9 @@
       "resources": {
         "files": [
           "/index.html",
-          "/client/assets/images/favicon.png",
-          "/client/*.bundle.css",
-          "/client/*.bundle.js",
-          "/client/*.chunk.js",
+          "/client/assets/images/icons/favicon.png",
+          "/client/*.css",
+          "/client/*.js",
           "/manifest.webmanifest"
         ]
       }
index 0f5b2d9763aea6848aa8e3f9df8639eb30ecf0f3..68939290c79ef159ee298ab30317298f4593aa34 100755 (executable)
@@ -70,6 +70,8 @@ else
     npm run ng build -- --localize=false --output-path "dist/$defaultLanguage/" --deploy-url "/client/$defaultLanguage/" --prod --stats-json $additionalParams
 fi
 
+mv "./dist/$defaultLanguage/ngsw-worker.js" "./dist/"
+
 cd ../ && npm run build:embed && cd client/
 
 # Copy runtime locales