Skip to content

Service Worker isn't registered #3

@pauloo27

Description

@pauloo27

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions