Chrome Dev Summit 2020 is back & going virtual on December 9-10. Learn more

Class: InjectManifest

Constructor

InjectManifest

new InjectManifest(config)

Creates an instance of InjectManifest.

Parameter

config

Object

The configuration to use.

Values in config have the following properties:

Parameter

swSrc

string

An existing service worker file that will be compiled and have a precache manifest injected into it.

additionalManifestEntries

Optional

Array of module:workbox-build.ManifestEntry

A list of entries to be precached, in addition to any entries that are generated as part of the build configuration.

chunks

Optional

Array of string

One or more chunk names whose corresponding output files should be included in the precache manifest.

compileSrc

Optional

boolean

When true (the default), the swSrc file will be compiled by webpack. When false, compilation will not occur (and webpackCompilationPlugins can't be used.) Set to false if you want to inject the manifest into, e.g., a JSON file.

dontCacheBustURLsMatching

Optional

RegExp

Assets that match this will be assumed to be uniquely versioned via their URL, and exempted from the normal HTTP cache-busting that's done when populating the precache. (As of Workbox v6, this option is usually not needed, as each asset's metadata is used to determine whether it's immutable or not.)

exclude

Optional

Array of (string, RegExp, or function())

One or more specifiers used to exclude assets from the precache manifest. This is interpreted following the same rules as webpack's standard exclude option.

excludeChunks

Optional

Array of string

One or more chunk names whose corresponding output files should be excluded from the precache manifest.

include

Optional

Array of (string, RegExp, or function())

One or more specifiers used to include assets in the precache manifest. This is interpreted following the same rules as webpack's standard include option.

injectionPoint

Optional

string

The string to find inside of the swSrc file. Once found, it will be replaced by the generated precache manifest.

manifestTransforms

Optional

Array of module:workbox-build.ManifestTransform

One or more functions which will be applied sequentially against the generated manifest. If modifyURLPrefix or dontCacheBustURLsMatching are also specified, their corresponding transformations will be applied first.

maximumFileSizeToCacheInBytes

Optional

number

This value can be used to determine the maximum size of files that will be precached. This prevents you from inadvertently precaching very large files that might have accidentally matched one of your patterns.

mode

Optional

string

If set to 'production', then an optimized service worker bundle that excludes debugging info will be produced. If not explicitly configured here, the mode value configured in the current webpack compilation will be used.

modifyURLPrefix

Optional

Object with string properties

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.

swDest

Optional

string

The asset name of the service worker file that will be created by this plugin. If omitted, the name will be based on the swSrc name.

webpackCompilationPlugins

Optional

Array of Object

Optional webpack plugins that will be used when compiling the swSrc input file.