0

I'm trying to develop my ejected react app to work as a PWA. I am using workboxWebpackPlugin. The serviceWorker is registered and apparently caching is working fine.

here is my webpack config:

new WorkboxWebpackPlugin.GenerateSW({
        clientsClaim: true,
        exclude: [/\.map$/, /asset-manifest\.json$/],
        // importWorkboxFrom: "cdn",
        navigateFallback: "/static-files/fallback.html",
        navigateFallbackBlacklist: [
          // Exclude URLs starting with /_, as they're likely an API call
          new RegExp("^/_"),
          // Exclude URLs containing a dot, as they're likely a resource in
          // public/ and not a SPA route
          new RegExp("/[^/]+\\.[^/]+$"),
        ],
        importsDirectory: __dirname + "/../build/static-files",
        swDest: "static-files/shab-sw.js",
      }),

enter image description here

the problem I'm facing now is that the navigateFallback is not working and console is returning the following error:

error has occured: ChunkLoadError: Loading chunk 28 failed.

would appreciate any help in advance

S.Aminnejad
  • 109
  • 1
  • 3
  • 12
  • That error might be unrelated to the service worker behavior you're reporting. Do you have your web app deployed at a public URL so that we can take a look? – Jeff Posnick Feb 02 '21 at 19:22
  • Hi. Yes here is the URL. By the way my app is not in English but the configs are straight forward https://www.shab.ir/ – S.Aminnejad Feb 09 '21 at 10:45
  • Your service worker is being served from https://www.shab.ir/static-files/shab-sw.js, which means that its scope only allows it to control pages whose URLs start with `https://www.shab.ir/static-files/` – Jeff Posnick Feb 09 '21 at 16:43

0 Answers0