Hello, I'm trying to create a Service Worker to a React PWA.
I never used Parcel before so maybe I did something wrong.
The usage in the README says:
When you build resources with Parcel, the plugin will generate a service worker sw.js and insert it into your project's index.html entry file.
I've created a .workbox-config.js using workbox wizard but the sw.js isn't created and neither added to the index.html and I don't know why.
I tried to "install" the service worker manually: I used workbox generateSW .workbox-config.js and manually added a script that loads the sw.js file in dist/index.html to check if the generated sw.js was ok and it was, the service worker was loaded.
Have I missed a step?
The content of the .workbox-config.js:
module.exports = {
"globDirectory": "dist/",
"globPatterns": [
"**/*.{js,css,html,webmanifest}"
],
"swDest": "dist/sw.js",
"maximumFileSizeToCacheInBytes": 5000000,
};
I start parcel with the following yarn script: "start": "rm -r dist/; rm -r .parcel-cache; parcel index.html".
My dependencies:
"dependencies": {
"@fortawesome/fontawesome-svg-core": "^1.2.32",
"@fortawesome/free-solid-svg-icons": "^5.15.1",
"@fortawesome/react-fontawesome": "^0.1.14",
"@types/react-router-dom": "^5.1.6",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-router-dom": "^5.2.0",
"zustand": "^3.2.0"
},
"devDependencies": {
"@babel/preset-typescript": "^7.10.4",
"@types/react": "^16.9.34",
"@types/react-dom": "^16.9.7",
"babel-preset-nano-react-app": "^0.1.0",
"parcel": "^2.0.0-alpha.3.2",
"parcel-plugin-workbox-cache": "^2.0.1",
"typescript": "^3.8.3"
},
Thanks in advance.
Hello, I'm trying to create a Service Worker to a React PWA.
I never used Parcel before so maybe I did something wrong.
The usage in the README says:
I've created a
.workbox-config.jsusingworkbox wizardbut thesw.jsisn't created and neither added to the index.html and I don't know why.I tried to "install" the service worker manually: I used
workbox generateSW .workbox-config.jsand manually added a script that loads thesw.jsfile indist/index.htmlto check if the generatedsw.jswas ok and it was, the service worker was loaded.Have I missed a step?
The content of the
.workbox-config.js:I start parcel with the following yarn script:
"start": "rm -r dist/; rm -r .parcel-cache; parcel index.html".My dependencies:
Thanks in advance.