I have created PWA and implementef workbox using workbox-webpack-plugin
.
I got error when i tried to precache the files.
the error that i got (see image below)
sw.js:1 Uncaught TypeError: e is not iterable
at d.addToCacheList (sw.js:1)
at sw.js:1
at sw.js:1
at sw.js:1
although self.__WB_MANIFEST
return correctly
0: {revision: "8601238f233fac234d7baf4d32a932d8", url: "favicon.ico"}
10: {revision: "70d6d945809b3a4bde074fb5a8e1a6ac", url: "register.js"}
I tried debugging workbox-precaching
but got stuck due to no gulpfile provided.
i cannot find gulpfile on node_modules/workbox-precaching
.
Here the detail of my code src/sw.js
import { precacheAndRoute } from 'workbox-precaching';
console.log(self.__WB_MANIFEST)
precacheAndRoute(self.__WB_MANIFEST);
webpack.config.js
plugins: [
...
new WorkboxPlugin.InjectManifest({
swSrc: './src/sw.js',
swDest: 'sw.js',
})
],
register.js
if ("serviceWorker" in navigator) {
window.addEventListener("load", function () {
navigator.serviceWorker
.register("sw.js")
.then(function (registration) {
console.log(location.href, registration.scope);
})
.catch(function (error) {
console.log(error)
});
});
package.json
"webpack": "^5.4.0",
"webpack-cli": "3.3.12",
"workbox-webpack-plugin": "^5.1.4