@@ -15,6 +15,7 @@ const validate = require('./lib/validate-options');
1515const writeServiceWorkerUsingDefaultTemplate =
1616 require ( './lib/write-sw-using-default-template' ) ;
1717
18+ // eslint-disable-next-line jsdoc/newline-after-description
1819/**
1920 * This method creates a list of URLs to precache, referred to as a "precache
2021 * manifest", based on the options you provide.
@@ -25,8 +26,164 @@ const writeServiceWorkerUsingDefaultTemplate =
2526 * Based on the precache manifest and the additional configuration, it writes
2627 * a ready-to-use service worker file to disk at `swDest`.
2728 *
28- * @param {Object } config Please refer to the
29- * [configuration guide](https://developers.google.com/web/tools/workbox/modules/workbox-build#full_generatesw_config).
29+ * @param {Object } config The configuration to use.
30+ *
31+ * @param {string } config.globDirectory The local directory you wish to match
32+ * `globPatterns` against. The path is relative to the current directory.
33+ *
34+ * @param {string } config.swDest The path and filename of the service worker file
35+ * that will be created by the build process, relative to the current working
36+ * directory. It must end in '.js'.
37+ *
38+ * @param {Array<ManifestEntry> } [config.additionalManifestEntries] A list of
39+ * entries to be precached, in addition to any entries that are generated as
40+ * part of the build configuration.
41+ *
42+ * @param {Array<string> } [config.babelPresetEnvTargets=['chrome >= 56']]
43+ * The [targets](https://babeljs.io/docs/en/babel-preset-env#targets) to pass to
44+ * `babel-preset-env` when transpiling the service worker bundle.
45+ *
46+ * @param {string } [config.cacheId] An optional ID to be prepended to cache
47+ * names. This is primarily useful for local development where multiple sites
48+ * may be served from the same `http://localhost:port` origin.
49+ *
50+ * @param {boolean } [config.cleanupOutdatedCaches=false] Whether or not Workbox
51+ * should attempt to identify an delete any precaches created by older,
52+ * incompatible versions.
53+ *
54+ * @param {boolean } [config.clientsClaim=false] Whether or not the service
55+ * worker should [start controlling](https://developers.google.com/web/fundamentals/primers/service-workers/lifecycle#clientsclaim)
56+ * any existing clients as soon as it activates.
57+ *
58+ * @param {string } [config.directoryIndex='index.html'] If a navigation request
59+ * for a URL ending in `/` fails to match a precached URL, this value will be
60+ * appended to the URL and that will be checked for a precache match. This
61+ * should be set to what your web server is using for its directory index.
62+ *
63+ * @param {RegExp } [config.dontCacheBustURLsMatching] Assets that match this will be
64+ * assumed to be uniquely versioned via their URL, and exempted from the normal
65+ * HTTP cache-busting that's done when populating the precache. While not
66+ * required, it's recommended that if your existing build process already
67+ * inserts a `[hash]` value into each filename, you provide a RegExp that will
68+ * detect that, as it will reduce the bandwidth consumed when precaching.
69+ *
70+ * @param {boolean } [config.globFollow=true] Determines whether or not symlinks
71+ * are followed when generating the precache manifest. For more information, see
72+ * the definition of `follow` in the `glob`
73+ * [documentation](https://github.com/isaacs/node-glob#options).
74+ *
75+ * @param {Array<string> } [config.globIgnores=['node_modules/**']]
76+ * A set of patterns matching files to always exclude when generating the
77+ * precache manifest. For more information, see the definition of `ignore` in the `glob`
78+ * [documentation](https://github.com/isaacs/node-glob#options).
79+ *
80+ * @param {Array<string> } [config.globPatterns=['**.{js,css,html}']]
81+ * Files matching any of these patterns will be included in the precache
82+ * manifest. For more information, see the
83+ * [`glob` primer](https://github.com/isaacs/node-glob#glob-primer).
84+ *
85+ * @param {boolean } [config.globStrict=true] If true, an error reading a directory when
86+ * generating a precache manifest will cause the build to fail. If false, the
87+ * problematic directory will be skipped. For more information, see the
88+ * definition of `strict` in the `glob`
89+ * [documentation](https://github.com/isaacs/node-glob#options).
90+ *
91+ * @param {Array<RegExp> } [config.ignoreURLParametersMatching=[/^utm_/]]
92+ * Any search parameter names that match against one of the RegExp in this array
93+ * will be removed before looking for a precache match. This is useful if your
94+ * users might request URLs that contain, for example, URL parameters used to
95+ * track the source of the traffic.
96+ *
97+ * @param {Array<string> } [config.importScripts] A list of JavaScript files that
98+ * should be passed to [`importScripts()`](https://developer.mozilla.org/en-US/docs/Web/API/WorkerGlobalScope/importScripts)
99+ * inside the generated service worker file. This is useful when you want to
100+ * let Workbox create your top-level service worker file, but want to include
101+ * some additional code, such as a push event listener.
102+ *
103+ * @param {boolean } [config.inlineWorkboxRuntime=false] Whether the runtime code
104+ * for the Workbox library should be included in the top-level service worker,
105+ * or split into a separate file that needs to be deployed alongside the service
106+ * worker. Keeping the runtime separate means that users will not have to
107+ * re-download the Workbox code each time your top-level service worker changes.
108+ *
109+ * @param {Array<ManifestTransform> } [config.manifestTransforms] One or more
110+ * functions which will be applied sequentially against the generated manifest.
111+ * If `modifyURLPrefix` or `dontCacheBustURLsMatching` are also specified, their
112+ * corresponding transformations will be applied first.
113+ *
114+ * @param {number } [config.maximumFileSizeToCacheInBytes=2097152] This value can be
115+ * used to determine the maximum size of files that will be precached. This
116+ * prevents you from inadvertently precaching very large files that might have
117+ * accidentally matched one of your patterns.
118+ *
119+ * @param {string } [config.mode='production'] If set to 'production', then an
120+ * optimized service worker bundle that excludes debugging info will be
121+ * produced. If not explicitly configured here, the `process.env.NODE_ENV` value
122+ * will be used, and failing that, it will fall back to `'production'`.
123+ *
124+ * @param {Object<string, string> } [config.modifyURLPrefix] A mapping of prefixes
125+ * that, if present in an entry in the precache manifest, will be replaced with
126+ * the corresponding value. This can be used to, for example, remove or add a
127+ * path prefix from a manifest entry if your web hosting setup doesn't match
128+ * your local filesystem setup. As an alternative with more flexibility, you can
129+ * use the `manifestTransforms` option and provide a function that modifies the
130+ * entries in the manifest using whatever logic you provide.
131+ *
132+ * @param {string } [config.navigateFallback] If specified, all
133+ * [navigation requests](https://developers.google.com/web/fundamentals/primers/service-workers/high-performance-loading#first_what_are_navigation_requests)
134+ * for URLs that aren't precached will be fulfilled with the HTML at the URL
135+ * provided. You must pass in the URL of an HTML document that is listed in your
136+ * precache manifest. This is meant to be used in a Single Page App scenario, in
137+ * which you want all navigations to use common [App Shell HTML](https://developers.google.com/web/fundamentals/architecture/app-shell).
138+ *
139+ * @param {Array<RegExp> } [config.navigateFallbackBlacklist] An optional array
140+ * of regular expressions that restricts which URLs the configured
141+ * `navigateFallback` behavior applies to. This is useful if only a subset of
142+ * your site's URLs should be treated as being part of a
143+ * [Single Page App](https://en.wikipedia.org/wiki/Single-page_application). If
144+ * both `navigateFallbackBlacklist` and `navigateFallbackWhitelist` are
145+ * configured, the blacklist takes precedent.
146+ *
147+ * @param {Array<RegExp> } [config.navigateFallbackWhitelist] An optional array
148+ * of regular expressions that restricts which URLs the configured
149+ * `navigateFallback` behavior applies to. This is useful if only a subset of
150+ * your site's URLs should be treated as being part of a
151+ * [Single Page App](https://en.wikipedia.org/wiki/Single-page_application). If
152+ * both `navigateFallbackBlacklist` and `navigateFallbackWhitelist` are
153+ * configured, the blacklist takes precedent.
154+ *
155+ * @param {boolean } [config.navigationPreload=false] Whether or not to enable
156+ * [navigation preload](https://developers.google.com/web/tools/workbox/modules/workbox-navigation-preload)
157+ * in the generated service worker. When set to true, you must also use
158+ * `runtimeCaching` to set up an appropriate response strategy that will match
159+ * navigation requests, and make use of the preloaded response.
160+ *
161+ * @param {boolean|Object } [config.offlineGoogleAnalytics=false] Controls
162+ * whether or not to include support for
163+ * [offline Google Analytics](https://developers.google.com/web/tools/workbox/guides/enable-offline-analytics).
164+ * When `true`, the call to `workbox-google-analytics`'s `initialize()` will be
165+ * added to your generated service worker. When set to an `Object`, that object
166+ * will be passed in to the `initialize()` call, allowing you to customize the
167+ * behavior.
168+ *
169+ * @param {Array<RuntimeCachingEntry> } [config.runtimeCaching]
170+ *
171+ * @param {boolean } [config.skipWaiting=false] Whether to add an
172+ * unconditional call to [`skipWaiting()`]{@link module:workbox-core.skipWaiting}
173+ * to the generated service worker. If `false`, then a `message` listener will
174+ * be added instead, allowing you to conditionally call `skipWaiting()`.
175+ *
176+ * @param {boolean } [config.sourcemap=true] Whether to create a sourcemap
177+ * for the generated service worker files.
178+ *
179+ * @param {Object } [config.templatedURLs] If a URL is rendered based on some
180+ * server-side logic, its contents may depend on multiple files or on some other
181+ * unique string value. The keys in this object are server-rendered URLs. If the
182+ * values are an array of strings, they will be interpreted as `glob` patterns,
183+ * and the contents of any files matching the patterns will be used to uniquely
184+ * version the URL. If used with a single string, it will be interpreted as
185+ * unique versioning information that you've generated for a given URL.
186+ *
30187 * @return {Promise<{count: number, filePaths: Array<string>, size: number, warnings: Array<string>}> }
31188 * A promise that resolves once the service worker and related files
32189 * (indicated by `filePaths`) has been written to `swDest`. The `size` property
0 commit comments