Based on your message this steps were done using [email protected].
Edit service worker file.
- Open the file
<project_name>/node_modules/@angular/service-worker/ngsw-worker.js
- Search
handleFetch function
Line 1121.
- Edit adapt that function with your requirement. Check out
handleFetchWithFreshness
and handleFetchWithPerformance
as examples.
- Save
Patch file
- Use patch-package to save patch.
npx patch-package @angular/service-worker
- Make a commit.
- Add
postinstall script
to package.json
"scripts": {
"postinstall": "patch-package"
}
- Add
patch-package
package npm install --save-dev patch-package
Test service worker
- ng build.
- start a server of dist files.
- it should works.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…