English
GeneratePartial
Interface workbox-buildProperties
| Property | Type | Default | Description |
|---|---|---|---|
cacheId? | string | null | An optional ID to be prepended to cache names. This is primarily useful for local development where multiple sites may be served from the same http://localhost:port origin. | |
cleanupOutdatedCaches? | boolean | false | Whether or not Workbox should attempt to identify and delete any precaches created by older, incompatible versions. |
cleanURLs? | boolean | true | Whether to clean up search parameters from URLs. |
clientsClaim? | boolean | false | Whether or not the service worker should start controlling any existing clients as soon as it activates. |
directoryIndex? | string | null | If a navigation request for a URL ending in / fails to match a precached URL, this value will be appended to the URL and that will be checked for a precache match. This should be set to what your web server is using for its directory index. | |
disableDevLogs? | boolean | false | |
ignoreURLParametersMatching? | RegExp[] | Any search parameter names that match against one of the RegExp in this array will be removed before looking for a precache match. This is useful if your users might request URLs that contain, for example, URL parameters used to track the source of the traffic. If not provided, the default value is [/^utm_/, /^fbclid$/]. | |
inlineWorkboxRuntime? | boolean | false | Whether the runtime code for the Workbox library should be included in the top-level service worker, or split into a separate file that needs to be deployed alongside the service worker. Keeping the runtime separate means that users will not have to re-download the Workbox code each time your top-level service worker changes. |
minify? | boolean | Should minify the output? - when specified it is preserved - true when sourcemap is not set to false or mode is set to production - otherwise false | |
mode? | string | null | "production" | If set to 'production', then an optimized service worker bundle that excludes debugging info will be produced. If not explicitly configured here, the process.env.NODE_ENV value will be used, and failing that, it will fall back to 'production'. |
navigateFallback? | string | null | null | If specified, all navigation requests for URLs that aren't precached will be fulfilled with the HTML at the URL provided. You must pass in the URL of an HTML document that is listed in your precache manifest. This is meant to be used in a Single Page App scenario, in which you want all navigations to use common App Shell HTML. |
navigateFallbackAllowlist? | RegExp[] | An optional array of regular expressions that restricts which URLs the configured navigateFallback behavior applies to. This is useful if only a subset of your site's URLs should be treated as being part of a Single Page App. If both navigateFallbackDenylist and navigateFallbackAllowlist are configured, the denylist takes precedent.Note*: These RegExps may be evaluated against every destination URL during a navigation. Avoid using complex RegExps, or else your users may see delays when navigating your site. | |
navigateFallbackDenylist? | RegExp[] | An optional array of regular expressions that restricts which URLs the configured navigateFallback behavior applies to. This is useful if only a subset of your site's URLs should be treated as being part of a Single Page App. If both navigateFallbackDenylist and navigateFallbackAllowlist are configured, the denylist takes precedent.Note*: These RegExps may be evaluated against every destination URL during a navigation. Avoid using complex RegExps, or else your users may see delays when navigating your site. | |
navigationPreload? | boolean | false | Whether or not to enable navigation preload in the generated service worker. When set to true, you must also use runtimeCaching to set up an appropriate response strategy that will match navigation requests, and make use of the preloaded response. |
parallel? | Parallel | Controls parallel precaching of assets during service worker installation. When enabled, assets are fetched concurrently up to concurrency at a time instead of one by one.Limiting concurrency prevents net::ERR_INSUFFICIENT_RESOURCES errors in Chrome and reduces bandwidth impact on the main app during service worker installation. | |
runtimeCaching? | RuntimeCaching[] | When using Workbox's build tools to generate your service worker, you can specify one or more runtime caching configurations. These are then translated to workbox-routing.registerRoute calls using the match and handler configuration you define. For all of the options, see the workbox-build.RuntimeCaching documentation. The example below shows a typical configuration, with two runtime routes defined: Example: | |
skipWaiting? | boolean | false | Whether to add an unconditional call to skipWaiting() to the generated service worker. If false, then a message listener will be added instead, allowing client pages to trigger skipWaiting() by calling postMessage({type: 'SKIP_WAITING'}) on a waiting service worker. |
sourcemap? | boolean | "hidden" | "inline" | false | Whether to create a sourcemap for the generated service worker files. - false: No sourcemap will be generated.- true: A separate sourcemap file will be generated.- inline: The sourcemap will be appended to the output file as a data URL.- hidden: A separate sourcemap file will be generated, but the link to the sourcemap (//# sourceMappingURL comment) will not be included in the output file. |
swType? | T | classic | The type of the service worker. |
target? | SWTarget | undefined | Service worker target build. |
urlManipulation? | (options: { url: URL }) => URL[] | A callback function that allows you to modify the URL of a precached asset before it's looked up in the cache. | |
workboxRuntimeCompatible? | boolean | true | When using classic or module and splitting workbox runtime (inlineWorkboxRuntime set to false), this flag controls the name of the workbox-**.js chunk:- when true, workbox will generate the same old asset name workbox-<hash>.js using hex- when false, workbox will generate workbox-classic-<hash>.js or workbox-module-<hash>.js with modern Vite/Rolldown hash.When using classic-and-module (dual build), the build will use modern Vite/Rolldown hash regardless of the value of this flag. |