0
votes

I am trying to set up WorkboxPlugin for Webpack, i did follow the tutorial provided on https://developers.google.com/web/tools/workbox/guides/get-started but can't get rid of the last failed audit:

Users will not be prompted to install the Web App: Failures: service worker does not successfully serve the manifest's start url

I basically provide a offline page /offline but couldn't figure out how to route it in the plugin.

webpackplugin:

  new WorkboxPlugin.GenerateSW({
            swDest: 'sw.js',
            clientsClaim: true,
            skipWaiting: true,
            runtimeCaching: [
                {
                    urlPattern: new RegExp('/offline'),
                    handler: 'staleWhileRevalidate',
                },
                {
                    urlPattern: new RegExp('/'),
                    handler: 'staleWhileRevalidate',
                },
            ],
        }),
    ],

the startUrl in my manifest points to : "start_url": "./",

the generated sw.js:

importScripts("https://storage.googleapis.com/workbox-cdn/releases/3.1.0/workbox-sw.js");

importScripts(
  "/precache-manifest.b0461f0dafa721eb54bbbe7cf6e3d452.js"
);

self.__precacheManifest = [].concat(self.__precacheManifest || []);
workbox.precaching.suppressWarnings();
workbox.precaching.precacheAndRoute(self.__precacheManifest, {});

workbox.routing.registerRoute(/\/offline/, workbox.strategies.staleWhileRevalidate(), 'GET');
workbox.routing.registerRoute(/\//, workbox.strategies.staleWhileRevalidate(), 'GET');

the precache-manifest looks fine as well

What am i missing?

Much appreciated!

1

1 Answers

1
votes

The fix was to set "start_url": "./" to the Webapps url e.g:

"start_url": "https://webapp.app"