I was having service worker implemented in angular.js application where we have some custom code written in self.addEventListener('fetch', function (event)
. Now i am planning to migrate the application to angular, and i found in angular we have the special plugin which will do all configuration and cache cleanup. "@angular/service-worker": "~10.0.6",
.
Now i am suffering to have the custom code implemented inside fetch event to integrate in angular version. Is there any way we can have the fetch method override in to a component and do the operation from there.
Based on your message this steps were done using [email protected].
Edit service worker file.
<project_name>/node_modules/@angular/service-worker/ngsw-worker.js
handleFetch function
Line 1121.handleFetchWithFreshness
andhandleFetchWithPerformance
as examples.Patch file
npx patch-package @angular/service-worker
postinstall script
topackage.json
patch-package
packagenpm install --save-dev patch-package
Test service worker