workbox-build
Advanced tools
Comparing version 1.3.0 to 2.0.0
@@ -16,3 +16,3 @@ 'use strict'; | ||
* This module will use glob patterns to find assets in a given directory | ||
* and use the resulting URL and hash data for one of the follow uses: | ||
* and use the resulting URL and revision data for one of the follow uses: | ||
* | ||
@@ -35,52 +35,313 @@ * 1. Generate a complete service worker with precaching and some basic | ||
* | ||
* @example <caption>Generate a complete service worker that will precache | ||
* the discovered assets.</caption> | ||
* const swBuild = require('workbox-build'); | ||
* @module workbox-build | ||
*/ | ||
/** | ||
* These are the full set of options that could potentially be used to configure | ||
* one of the build tools. Each of the build tools has a slightly different way | ||
* of providing this configuration: | ||
* | ||
* swBuild.generateSW({ | ||
* globDirectory: './build/', | ||
* globPatterns: ['**\/*.{html,js,css}'], | ||
* globIgnores: ['service-worker.js','admin.html'], | ||
* swDest: './build/sw.js', | ||
* templatedUrls: { | ||
* '/shell': ['shell.hbs', 'main.css', 'shell.css'], | ||
* }, | ||
* }) | ||
* .then(() => { | ||
* console.log('Service worker generated.'); | ||
* }); | ||
* - When using the `workbox-build` module directly, pass the | ||
* configuration object to appropriate method. For example, | ||
* `workboxBuild.injectManifest(configuration)` or | ||
* `workboxBuild.generateSW(configuration)`. | ||
* | ||
* @example <caption>Generate a file containing the assets to precache. | ||
* </caption> | ||
* const swBuild = require('workbox-build'); | ||
* - When using the `workbox-cli` command line interface, use the | ||
* `--config-file` flag to point to a | ||
* [CommonJS module file](https://nodejs.org/docs/latest/api/modules.html) that | ||
* assigns the configuration object to `module.exports`. | ||
* | ||
* swBuild.generateFileManifest({ | ||
* globDirectory: './build/', | ||
* globPatterns: ['**\/*.{html,js,css}'], | ||
* globIgnores: ['service-worker.js','admin.html'], | ||
* manifestDest: './build/scripts/manifest.js', | ||
* templatedUrls: { | ||
* '/shell': ['shell.hbs', 'main.css', 'shell.css'], | ||
* }, | ||
* }) | ||
* .then(() => { | ||
* console.log('Build file has been created.'); | ||
* }); | ||
* - When using `workbox-webpack-plugin` within a | ||
* [Webpack](https://webpack.js.org/) build, pass the configuration object to | ||
* the plugin's constructor, like | ||
* `new WorkboxBuildWebpackPlugin(configuration)`. | ||
* | ||
* @example <caption>Get an Array of files with revision details.</caption> | ||
* const swBuild = require('workbox-build'); | ||
* Some specific options might not make sense with certain combinations of | ||
* interfaces. In those cases, the limitations are called out in the | ||
* documentation, and may lead to build-time warnings or errors. | ||
* | ||
* swBuild.getFileManifestEntries({ | ||
* globDirectory: './build/', | ||
* globPatterns: ['**\/*.{html,js,css}'], | ||
* globIgnores: ['service-worker.js','admin.html'], | ||
* templatedUrls: { | ||
* '/shell': ['shell.hbs', 'main.css', 'shell.css'], | ||
* Each option documented here includes an example, which, for the sake of | ||
* illustration, assumes the following local filesystem setup. Please adjust | ||
* the example values to match your actual setup. | ||
* | ||
* ```sh | ||
* ./ | ||
* ├── dev/ | ||
* │ ├── app.js | ||
* │ ├── ignored.html | ||
* │ ├── image.png | ||
* │ ├── index.html | ||
* │ ├── main.css | ||
* │ ├── sw.js | ||
* │ └── templates/ | ||
* │ └── app_shell.hbs | ||
* └── dist/ | ||
* ├── app.js | ||
* ├── image.png | ||
* ├── index.html | ||
* ├── main.css | ||
* └── sw.js | ||
* ``` | ||
* | ||
* @typedef {Object} Configuration | ||
* | ||
* @property {String} swDest The path to the final service worker | ||
* file that will be created by the build process, relative to the current | ||
* working directory. | ||
* | ||
* E.g.: `'./dist/sw.js'` | ||
* | ||
* @property {String} swSrc The path to the source service worker | ||
* containing a `precache([])` placeholder, which will be replaced with the | ||
* precache manifest generated by the build. | ||
* | ||
* E.g.: `'./dev/sw.js'` | ||
* | ||
* Note: This option is only valid when used with | ||
* {@link module:workbox-build.injectManifest|injectManifest()}. | ||
* | ||
* @property {Array<String>} [globPatterns=['**\/*.{js,css,html}']] | ||
* Files matching against any of these | ||
* [glob patterns](https://github.com/isaacs/node-glob) will be included in the | ||
* precache manifest. | ||
* | ||
* E.g.: `'**\/*.{js,css,html,png}'` | ||
* | ||
* @property {String} globDirectory The base directory you wish to | ||
* match `globPatterns` against, related to the current working directory. | ||
* | ||
* E.g.: `'./dev'` | ||
* | ||
* @property {String|Array<String>} [globIgnores='node_modules'] | ||
* Files matching against any of these glob patterns will be excluded from the | ||
* file manifest, overriding any matches from `globPatterns`. | ||
* | ||
* E.g. `['**\/ignored.html']` | ||
* | ||
* @property {Object<String,Array|String>} [templatedUrls] | ||
* If a URL is rendered generated based on some server-side logic, its contents | ||
* may depend on multiple files or on some other unique string value. | ||
* | ||
* If used with an array of strings, they will be interpreted as | ||
* [glob patterns](https://github.com/isaacs/node-glob), and the contents of | ||
* any files matching the patterns will be used to uniquely version the URL. | ||
* | ||
* If used with a single string, it will be interpreted as unique versioning | ||
* information that you've generated out of band for a given URL. | ||
* | ||
* E.g. | ||
* ```js | ||
* { | ||
* '/app-shell': [ | ||
* 'dev/templates/app-shell.hbs', | ||
* 'dev/**\/*.css', | ||
* ], | ||
* '/other-page': 'my-version-info', | ||
* } | ||
* ``` | ||
* | ||
* @property {number} [maximumFileSizeToCacheInBytes=2097152] | ||
* This value can be used to determine the maximum size of files that will be | ||
* precached. This prevents you from inadvertantly precaching very large files | ||
* that might have been accidentally match your `globPatterns` values. | ||
* | ||
* @property {Array<ManifestTransform>} [manifestTransforms] An array of | ||
* manifest transformations, which will be applied sequentially against the | ||
* generated manifest. If `modifyUrlPrefix` or `dontCacheBustUrlsMatching` are | ||
* also specified, their corresponding transformations will be applied first. | ||
* | ||
* See {@link module:workbox-build.ManifestTransform|ManifestTransform}. | ||
* | ||
* @property {Object<String,String>} [modifyUrlPrefix] A mapping of | ||
* prefixes that, if present in an entry in the precache manifest, will be | ||
* replaced with the corresponding value. | ||
* | ||
* This can be used to, for example, remove or add a path prefix from a manifest | ||
* entry if your web hosting setup doesn't match your local filesystem setup. | ||
* | ||
* As an alternative with more flexibility, you can use the `manifestTransforms` | ||
* option and provide a function that modifies the entries in the manifest using | ||
* whatever logic you provide. | ||
* | ||
* E.g. | ||
* ```js | ||
* { | ||
* '/prefix-to-remove': '', | ||
* } | ||
* ``` | ||
* | ||
* @property {RegExp} [dontCacheBustUrlsMatching] Assets that match this | ||
* regex will be assumed to be uniquely versioned via their URL, an exempted | ||
* from the normal HTTP cache-busting that's done when populating the precache. | ||
* | ||
* While not required, it's recommended that if your existing build process | ||
* already inserts a `[hash]` value into each filename, you provide a RegExp | ||
* that will detect those values, as it will reduce the amount of bandwidth | ||
* consumed when precaching. | ||
* | ||
* E.g. `/\.\w{8}\./` | ||
* | ||
* @property {String} [navigateFallback] This will be used to create a | ||
* {@link module:workbox-routing.NavigationRoute|NavigationRoute} that will | ||
* respond to navigation requests for URLs that that aren't precached. | ||
* | ||
* This is meant to be used in a | ||
* [Single Page App](https://en.wikipedia.org/wiki/Single-page_application) | ||
* scenario, in which you want all navigations to result in common App Shell | ||
* HTML being reused. | ||
* | ||
* It's *not* intended for use as a fallback that's displayed when the browser | ||
* is offline. | ||
* | ||
* Note: This option is only valid when used with | ||
* {@link module:workbox-build#generateSW|generateSW()}. When using | ||
* {@link module:workbox-build.injectManifest|injectManifest()}, you can | ||
* explicitly add in a call to | ||
* {@link module:workbox-sw.Router#registerNavigationRoute| | ||
* registerNavigationRoute()} | ||
* in your `swSrc` file. | ||
* | ||
* E.g. `'/app-shell'` | ||
* | ||
* @property {Array<RegExp>} [navigateFallbackWhitelist=/./] An optional | ||
* array of regular expressions that restrict which URLs the navigation route | ||
* applies to. | ||
* | ||
* Note: This option is only valid when used with | ||
* {@link module:workbox-build#generateSW|generateSW()}. When using | ||
* {@link module:workbox-build.injectManifest|injectManifest()}, you can | ||
* explicitly add in the whitelist when calling | ||
* {@link module:workbox-sw.Router#registerNavigationRoute| | ||
* registerNavigationRoute()} | ||
* in your `swSrc` file. | ||
* | ||
* E.g. `[/pages/, /articles/]` | ||
* | ||
* @property {String} [cacheId] An optional ID to be prepended to caches | ||
* used by `workbox-sw`. This is primarily useful for local development where | ||
* multiple sites may be served from the same `http://localhost` origin. | ||
* | ||
* Note: This option is only valid when used with | ||
* {@link module:workbox-build#generateSW|generateSW()}. When using | ||
* {@link module:workbox-build.injectManifest|injectManifest()}, you can | ||
* explicitly pass the desired value in to the | ||
* {@link module:workbox-sw.WorkboxSW|WorkboxSW() constructor} in your `swSrc` | ||
* file. | ||
* | ||
* E.g. `'my-app-name'` | ||
* | ||
* @property {Boolean} [skipWaiting=false] Whether or not the service worker | ||
* should skip over the [waiting](https://developers.google.com/web/fundamentals/instant-and-offline/service-worker/lifecycle#waiting) | ||
* lifecycle stage. | ||
* | ||
* Note: This option is only valid when used with | ||
* {@link module:workbox-build#generateSW|generateSW()}. When using | ||
* {@link module:workbox-build.injectManifest|injectManifest()}, you can | ||
* explicitly pass the desired value in to the | ||
* {@link module:workbox-sw.WorkboxSW|WorkboxSW() constructor} in your `swSrc` | ||
* file. | ||
* | ||
* @property {Boolean} [clientsClaim=false] Whether or not the service worker | ||
* should [start controlling](https://developers.google.com/web/fundamentals/instant-and-offline/service-worker/lifecycle#clientsclaim) | ||
* any existing clients as soon as it activates. | ||
* | ||
* Note: This option is only valid when used with | ||
* {@link module:workbox-build#generateSW|generateSW()}. When using | ||
* {@link module:workbox-build.injectManifest|injectManifest()}, you can | ||
* explicitly pass the desired value in to the | ||
* {@link module:workbox-sw.WorkboxSW|WorkboxSW() constructor} in your `swSrc` | ||
* file. | ||
* | ||
* @property {string} [directoryIndex='index.html'] If a request for a URL | ||
* ending in '/' fails, this value will be appended to the URL and a second | ||
* request will be made. | ||
* | ||
* This should be configured to whatever your web server is using, if anything, | ||
* for its [directory index](https://httpd.apache.org/docs/2.0/mod/mod_dir.html). | ||
* | ||
* Note: This option is only valid when used with | ||
* {@link module:workbox-build#generateSW|generateSW()}. When using | ||
* {@link module:workbox-build.injectManifest|injectManifest()}, you can | ||
* explicitly pass the desired value in to the | ||
* {@link module:workbox-sw.WorkboxSW|WorkboxSW() constructor} in your `swSrc` | ||
* file. | ||
* | ||
* @property {Array<Object>} [runtimeCaching] Passing in an array of objects | ||
* containing `urlPattern`s, `handler`s, and potentially `option`s that will add | ||
* the appropriate code to the generated service worker to handle runtime | ||
* caching. | ||
* | ||
* Requests for precached URLs that are picked up via `globPatterns` are handled | ||
* by default, and don't need to be accomodated in `runtimeCaching`. | ||
* | ||
* The `handler` values correspond the names of the | ||
* {@link module:workbox-sw.Strategies|strategies} supported by `workbox-sw`. | ||
* | ||
* | ||
* Note: This option is only valid when used with | ||
* {@link module:workbox-build#generateSW|generateSW()}. When using | ||
* {@link module:workbox-build.injectManifest|injectManifest()}, you can | ||
* explicitly add in the corresponding runtime caching behavior via | ||
* {@link module:workbox-sw.Router#registerRoute|registerRoute()} in your | ||
* `swSrc` file. | ||
* | ||
* E.g. | ||
* ```js | ||
* [{ | ||
* // You can use a RegExp as the pattern: | ||
* urlPattern: /.jpg$/, | ||
* handler: 'cacheFirst', | ||
* // Any options provided will be used when | ||
* // creating the caching strategy. | ||
* options: { | ||
* cacheName: 'image-cache', | ||
* cacheExpiration: { | ||
* maxEntries: 10, | ||
* }, | ||
* }, | ||
* }) | ||
* .then((fileDetails) => { | ||
* // An array of file details include a `url` and `revision` parameter. | ||
* }); | ||
* }, { | ||
* // You can also use Express-style strings: | ||
* urlPattern: 'https://example.com/path/to/:file', | ||
* handler: 'staleWhileRevalidate', | ||
* options: { | ||
* cacheableResponse: { | ||
statuses: [0], | ||
* }, | ||
* }, | ||
* }] | ||
* ``` | ||
* | ||
* @module workbox-build | ||
* @property {Array<RegExp>} [ignoreUrlParametersMatching=[/^utm_/]] Any | ||
* search parameter names that match against one of the regex's 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. Those URL parameters | ||
* would normally cause the cache lookup to fail, since the URL strings used | ||
* as cache keys would not be expected to include them. | ||
* | ||
* You can use `[/./]` to ignore all URL parameters. | ||
* | ||
* Note: This option is only valid when used with | ||
* {@link module:workbox-build#generateSW|generateSW()}. When using | ||
* {@link module:workbox-build.injectManifest|injectManifest()}, you can | ||
* explicitly pass the desired value in to the | ||
* {@link module:workbox-sw.WorkboxSW|WorkboxSW() constructor} in your `swSrc` | ||
* file. | ||
* | ||
* E.g. `[/homescreen/]` | ||
* | ||
* @property {Boolean} [handleFetch=true] Whether or not `workbox-sw` should | ||
* create a `fetch` event handler that responds to network requests. This is | ||
* useful during development if you don't want the service worker serving stale | ||
* content. | ||
* | ||
* Note: This option is only valid when used with | ||
* {@link module:workbox-build#generateSW|generateSW()}. When using | ||
* {@link module:workbox-build.injectManifest|injectManifest()}, you can | ||
* explicitly pass the desired value in to the | ||
* {@link module:workbox-sw.WorkboxSW|WorkboxSW() constructor} in your `swSrc` | ||
* file. | ||
* | ||
* @memberof module:workbox-build | ||
*/ | ||
@@ -87,0 +348,0 @@ |
@@ -11,3 +11,3 @@ 'use strict'; | ||
* | ||
* @param {Object} input | ||
* @param {module:workbox-build.Configuration} input | ||
* @param {String} [input.format] There are some options for how the file | ||
@@ -23,35 +23,9 @@ * manifest is formatted in the final output. The format can be one of the | ||
* manifest should be written (i.e. `./build/precache-manifest.js`). | ||
* @param {String} input.globDirectory The directory you wish to run the | ||
* `globPatterns` against. | ||
* @param {Array<String>} input.globPatterns Files matching against any of | ||
* these glob patterns will be included in the file manifest. | ||
* @param {String|Array<String>} [input.globIgnores] Files matching against any | ||
* of these glob patterns will be excluded from the file manifest, even if the | ||
* file matches against a `globPatterns` pattern. | ||
* @param {Object<String,Array|String>} [input.templatedUrls] | ||
* If a URL is rendered with templates on the server, its contents may | ||
* depend on multiple files. This maps URLs to an array of file names, or to a | ||
* string value, that uniquely determines the URL's contents. | ||
* @param {String} [input.modifyUrlPrefix] An object of key value pairs | ||
* where URL's starting with the key value will be replaced with the | ||
* corresponding value. | ||
* @param {number} [input.maximumFileSizeToCacheInBytes] This value can be used | ||
* to determine the maximum size of files that will be precached. | ||
* @return {Promise} Resolves once the manifest file has been created. | ||
* | ||
* Defaults to 2MB. | ||
* @param {RegExp} [input.dontCacheBustUrlsMatching] Assets that match this | ||
* regex will not have their revision details included in the precache. This | ||
* is useful for assets that have revisioning details in the filename. | ||
* @param {Array<ManifestTransform>} [input.manifestTransforms] A list of | ||
* manifest transformations, which will be applied sequentially against the | ||
* generated manifest. If `modifyUrlPrefix` or `dontCacheBustUrlsMatching` are | ||
* also specified, their corresponding transformations will be applied first. | ||
* @return {Promise} The returned promise resolves once the manifest file has | ||
* been generated. | ||
* | ||
* @example <caption>Generate a build manifest of static assets, which can | ||
* used with a service worker.</caption> | ||
* const swBuild = require('workbox-build'); | ||
* const workboxBuild = require('workbox-build'); | ||
* | ||
* swBuild.generateFileManifest({ | ||
* workboxBuild.generateFileManifest({ | ||
* manifestDest: './build/manifest.js' | ||
@@ -64,3 +38,3 @@ * globDirectory: './build/', | ||
* .then(() => { | ||
* console.log('Build Manifest generated.'); | ||
* console.log('Build manifest generated.'); | ||
* }); | ||
@@ -67,0 +41,0 @@ * |
@@ -11,84 +11,19 @@ 'use strict'; | ||
/** | ||
* This method will generate a working service worker with an inlined | ||
* file manifest. | ||
* This method will generate a working service worker with code to precache | ||
* any assets found during the build process. | ||
* | ||
* @param {Object} input | ||
* @param {String} input.swDest The file path and name you wish to write the | ||
* service worker file to. | ||
* @param {String} input.globDirectory The directory you wish to run the | ||
* `globPatterns` against. | ||
* @param {Array<String>} input.globPatterns Files matching against any of | ||
* these glob patterns will be included in the file manifest. | ||
* @param {module:workbox-build.Configuration} input | ||
* @return {Promise} Resolves once the service worker has been generated. | ||
* | ||
* Defaults to ['**\/*.{js,css}'] | ||
* @param {String|Array<String>} [input.globIgnores] Files matching against any | ||
* of these glob patterns will be excluded from the file manifest, even if the | ||
* file matches against a `globPatterns` pattern. Defaults to ignoring | ||
* 'node_modules'. | ||
* @param {Object<String,Array|String>} [input.templatedUrls] | ||
* If a URL is rendered with templates on the server, its contents may | ||
* depend on multiple files. This maps URLs to an array of file names, or to a | ||
* string value, that uniquely determines the URL's contents. | ||
* @param {string} [input.navigateFallback] This URL will be used as a fallback | ||
* if a navigation request can't be fulfilled. Normally this URL would be | ||
* precached so it's always available. This is particularly useful for single | ||
* page apps where requests should go to a single URL. | ||
* @param {Array<Regexp>} [input.navigateFallbackWhitelist] An optional Array | ||
* of regexs to restrict which URL's use the `navigateFallback` URL. | ||
* @param {String} [input.cacheId] An optional ID to be prepended to caches | ||
* used by workbox-build. This is primarily useful for local development where | ||
* multiple sites may be served from the same `http://localhost` origin. | ||
* @param {Boolean} [input.skipWaiting] When set to true the generated service | ||
* worker activate immediately. | ||
* @example <caption>Generate a complete service worker that will precache | ||
* the discovered assets.</caption> | ||
* const workboxBuild = require('workbox-build'); | ||
* | ||
* Defaults to false. | ||
* @param {Boolean} [input.clientsClaim] When set to true the generated service | ||
* worker will claim any currently open pages. | ||
* | ||
* Defaults to false. | ||
* @param {string} [input.directoryIndex] If a request for a URL ending in '/' | ||
* fails, this value will be appended to the URL and a second request will be | ||
* made. | ||
* | ||
* Defaults to 'index.html'. | ||
* @param {Array<Object>} [input.runtimeCaching] Passing in an array of objects | ||
* containing a `urlPattern` and a `handler` parameter will add the appropriate | ||
* code to the service work to handle run time caching for URL's matching the | ||
* pattern with the associated handler behavior. | ||
* @param {String} [input.modifyUrlPrefix] An object of key value pairs | ||
* where URL's starting with the key value will be replaced with the | ||
* corresponding value. | ||
* @param {Array<RegExp>} [input.ignoreUrlParametersMatching] Any search | ||
* parameters matching against one of the regex's in this array will be removed | ||
* before looking for a cache match. | ||
* @param {Boolean} [input.handleFetch] When set to false all requests will | ||
* go to the network. This is useful during development if you don't want the | ||
* service worker from preventing updates. | ||
* | ||
* Defaults to true. | ||
* @param {number} [input.maximumFileSizeToCacheInBytes] This value can be used | ||
* to determine the maximum size of files that will be precached. | ||
* | ||
* Defaults to 2MB. | ||
* @param {RegExp} [input.dontCacheBustUrlsMatching] Assets that match this | ||
* regex will not have their revision details included in the precache. This | ||
* is useful for assets that have revisioning details in the filename. | ||
* @param {Array<ManifestTransform>} [input.manifestTransforms] A list of | ||
* manifest transformations, which will be applied sequentially against the | ||
* generated manifest. If `modifyUrlPrefix` or `dontCacheBustUrlsMatching` are | ||
* also specified, their corresponding transformations will be applied first. | ||
* @return {Promise} Resolves once the service worker has been generated | ||
* with a precache list. | ||
* | ||
* @example <caption>Generate a service worker with precaching support. | ||
* </caption> | ||
* const swBuild = require('workbox-build'); | ||
* | ||
* swBuild.generateSW({ | ||
* swDest: './build/sw.js', | ||
* globDirectory: './build/', | ||
* workboxBuild.generateSW({ | ||
* globDirectory: './dist/', | ||
* globPatterns: ['**\/*.{html,js,css}'], | ||
* globIgnores: ['admin.html'], | ||
* swDest: './dist/sw.js', | ||
* templatedUrls: { | ||
* '/shell': ['shell.hbs', 'main.css', 'shell.css'], | ||
* '/shell': ['dev/templates/app-shell.hbs', 'dev/**\/*.css'], | ||
* }, | ||
@@ -95,0 +30,0 @@ * }) |
@@ -18,3 +18,2 @@ 'use strict'; | ||
/** | ||
@@ -24,31 +23,3 @@ * To get a list of files and revision details that can be used to ultimately | ||
* | ||
* @param {Object} input | ||
* @param {String} input.globDirectory The directory you wish to run the | ||
* `globPatterns` against. | ||
* @param {Array<String>} input.globPatterns Files matching against any of | ||
* these glob patterns will be included in the file manifest. | ||
* | ||
* Defaults to ['**\/*.{js,css}'] | ||
* @param {String|Array<String>} [input.globIgnores] Files matching against any | ||
* of these glob patterns will be excluded from the file manifest, even if the | ||
* file matches against a `globPatterns` pattern. Defaults to ignoring | ||
* 'node_modules'. | ||
* @param {Object<String,Array|String>} [input.templatedUrls] | ||
* If a URL is rendered with templates on the server, its contents may | ||
* depend on multiple files. This maps URLs to an array of file names, or to a | ||
* string value, that uniquely determines the URL's contents. | ||
* @param {String} [input.modifyUrlPrefix] An object of key value pairs | ||
* where URL's starting with the key value will be replaced with the | ||
* corresponding value. | ||
* @param {number} [input.maximumFileSizeToCacheInBytes] This value can be used | ||
* to determine the maximum size of files that will be precached. | ||
* | ||
* Defaults to 2MB. | ||
* @param {RegExp} [input.dontCacheBustUrlsMatching] An optional regex that will | ||
* return a URL string and exclude the revision details for urls matching this | ||
* regex. Useful if you have assets with file revisions in the URL. | ||
* @param {Array<ManifestTransform>} [input.manifestTransforms] A list of | ||
* manifest transformations, which will be applied sequentially against the | ||
* generated manifest. If `modifyUrlPrefix` or `dontCacheBustUrlsMatching` are | ||
* also specified, their corresponding transformations will be applied first. | ||
* @param {module:workbox-build.Configuration} input | ||
* @return {Promise<Array<ManifestEntry>>} | ||
@@ -55,0 +26,0 @@ * An array of {@link module:workbox-build#ManifestEntry|ManifestEntries} |
@@ -11,55 +11,29 @@ 'use strict'; | ||
/** | ||
* This method will read an existing service worker file and replace an empty | ||
* precache() call, like: `.precache([])`, and replace the array with | ||
* an array of assets to precache. This allows the service worker | ||
* to efficiently cache assets for offline use. | ||
* This method will read an existing service worker file, find an instance of | ||
* `.precache([])`, and replace the empty array with the contents of a precache | ||
* manifest. This allows the service worker to efficiently cache assets for | ||
* offline use, while still giving you control over the rest of the service | ||
* worker's code. | ||
* | ||
* @param {Object} input | ||
* @param {String} input.swSrc File path and name of the service worker file | ||
* to read and inject the manifest into before writing to `swDest`. | ||
* @param {String} input.swDest The file path and name you wish to writh the | ||
* service worker file to. | ||
* @param {String} input.globDirectory The directory you wish to run the | ||
* `globPatterns` against. | ||
* @param {Array<String>} input.globPatterns Files matching against any of | ||
* these glob patterns will be included in the file manifest. | ||
* | ||
* Defaults to ['**\/*.{js,css}'] | ||
* @param {String|Array<String>} [input.globIgnores] Files matching against any | ||
* of these glob patterns will be excluded from the file manifest, even if the | ||
* file matches against a `globPatterns` pattern. | ||
* @param {Object<String,Array|String>} [input.templatedUrls] | ||
* If a URL is rendered with templates on the server, its contents may | ||
* depend on multiple files. This maps URLs to an array of file names, or to a | ||
* string value, that uniquely determines the URL's contents. | ||
* @param {String} [input.modifyUrlPrefix] An object of key value pairs | ||
* where URL's starting with the key value will be replaced with the | ||
* corresponding value. | ||
* @param {number} [input.maximumFileSizeToCacheInBytes] This value can be used | ||
* to determine the maximum size of files that will be precached. | ||
* | ||
* Defaults to 2MB. | ||
* @param {RegExp} [input.dontCacheBustUrlsMatching] An optional regex that will | ||
* return a URL string and exclude the revision details for urls matching this | ||
* regex. Useful if you have assets with file revisions in the URL. | ||
* @param {Array<ManifestTransform>} [input.manifestTransforms] A list of | ||
* manifest transformations, which will be applied sequentially against the | ||
* generated manifest. If `modifyUrlPrefix` or `dontCacheBustUrlsMatching` are | ||
* also specified, their corresponding transformations will be applied first. | ||
* @param {module:workbox-build.Configuration} input | ||
* @return {Promise} Resolves once the service worker has been written | ||
* with the injected precache list. | ||
* | ||
* @example <caption>Generate a build manifest of static assets, which could | ||
* then be used with a service worker.</caption> | ||
* const swBuild = require('workbox-build'); | ||
* @example <caption>Takes an existing service worker file that includes | ||
* a <code>precache([])</code> placeholder, and injects a manifest of discovered | ||
* assets into it.</caption> | ||
* const workboxBuild = require('workbox-build'); | ||
* | ||
* swBuild.injectManifest({ | ||
* globDirectory: './build/', | ||
* workboxBuild.injectManifest({ | ||
* swSrc: './dev/sw.js', | ||
* swDest: './dist/sw.js', | ||
* globDirectory: './dist/', | ||
* globPatterns: ['**\/*.{html,js,css}'], | ||
* globIgnores: ['admin.html'], | ||
* swSrc: './src/sw.js', | ||
* swDest: './build/sw.js', | ||
* templatedUrls: { | ||
* '/shell': ['dev/templates/app-shell.hbs', 'dev/**\/*.css'], | ||
* }, | ||
* }) | ||
* .then(() => { | ||
* console.log('Build Manifest generated.'); | ||
* console.log('Service worker generated.'); | ||
* }); | ||
@@ -66,0 +40,0 @@ * |
@@ -0,1 +1,3 @@ | ||
'use strict'; | ||
const glob = require('glob'); | ||
@@ -2,0 +4,0 @@ const path = require('path'); |
@@ -0,1 +1,3 @@ | ||
'use strict'; | ||
const errors = require('../errors'); | ||
@@ -2,0 +4,0 @@ |
{ | ||
"name": "workbox-build", | ||
"version": "1.3.0", | ||
"version": "2.0.0", | ||
"description": "A module that integrates into your build process, helping you generate a manifest of local files that workbox-sw should precache.", | ||
@@ -35,4 +35,4 @@ "keywords": [ | ||
"mkdirp": "^0.5.1", | ||
"workbox-sw": "^1.3.0" | ||
"workbox-sw": "^2.0.0" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
68457
1382
+ Addedworkbox-sw@2.1.3(transitive)
- Removedworkbox-sw@1.3.0(transitive)
Updatedworkbox-sw@^2.0.0