workbox-webpack-plugin

  • Version 7.3.0
  • Published
  • 131 kB
  • 5 dependencies
  • MIT license

Install

npm i workbox-webpack-plugin
yarn add workbox-webpack-plugin
pnpm add workbox-webpack-plugin

Overview

A plugin for your Webpack build process, helping you generate a manifest of local files that workbox-sw should precache.

Index

Variables

variable _default

const _default: {
GenerateSW: typeof GenerateSW;
InjectManifest: typeof InjectManifest;
};

    Classes

    class GenerateSW

    class GenerateSW {}
    • This class supports creating a new, ready-to-use service worker file as part of the webpack compilation process.

      Use an instance of GenerateSW in the [plugins array](https://webpack.js.org/concepts/plugins/#usage) of a webpack config.

      // The following lists some common options; see the rest of the documentation
      // for the full set of options and defaults.
      new GenerateSW({
      exclude: [/.../, '...'],
      maximumFileSizeToCacheInBytes: ...,
      navigateFallback: '...',
      runtimeCaching: [{
      // Routing via a matchCallback function:
      urlPattern: ({request, url}) => ...,
      handler: '...',
      options: {
      cacheName: '...',
      expiration: {
      maxEntries: ...,
      },
      },
      }, {
      // Routing via a RegExp:
      urlPattern: new RegExp('...'),
      handler: '...',
      options: {
      cacheName: '...',
      plugins: [..., ...],
      },
      }],
      skipWaiting: ...,
      });

      module:workbox-webpack-plugin

    constructor

    constructor(config?: GenerateSWConfig);
    • Creates an instance of GenerateSW.

    property config

    protected config: GenerateSWConfig;

      method addAssets

      addAssets: (compilation: webpack.Compilation) => Promise<void>;
      • Parameter compilation

        The webpack compilation.

      method apply

      apply: (compiler: webpack.Compiler) => void;
      • Parameter compiler

        default compiler object passed from webpack

      method propagateWebpackConfig

      propagateWebpackConfig: (compiler: webpack.Compiler) => void;
      • Parameter compiler

        default compiler object passed from webpack

      class InjectManifest

      class InjectManifest {}
      • This class supports compiling a service worker file provided via swSrc, and injecting into that service worker a list of URLs and revision information for precaching based on the webpack asset pipeline.

        Use an instance of InjectManifest in the [plugins array](https://webpack.js.org/concepts/plugins/#usage) of a webpack config.

        In addition to injecting the manifest, this plugin will perform a compilation of the swSrc file, using the options from the main webpack configuration.

        // The following lists some common options; see the rest of the documentation
        // for the full set of options and defaults.
        new InjectManifest({
        exclude: [/.../, '...'],
        maximumFileSizeToCacheInBytes: ...,
        swSrc: '...',
        });

        module:workbox-webpack-plugin

      constructor

      constructor(config: WebpackInjectManifestOptions);
      • Creates an instance of InjectManifest.

      property config

      protected config: WebpackInjectManifestOptions;

        method addAssets

        addAssets: (compilation: webpack.Compilation) => Promise<void>;
        • Parameter compilation

          The webpack compilation.

        method addSrcToAssets

        addSrcToAssets: (
        compilation: webpack.Compilation,
        parentCompiler: webpack.Compiler
        ) => void;
        • Parameter compilation

          The webpack compilation.

          Parameter parentCompiler

          The webpack parent compiler.

        method apply

        apply: (compiler: webpack.Compiler) => void;
        • Parameter compiler

          default compiler object passed from webpack

        method handleMake

        handleMake: (
        compilation: webpack.Compilation,
        parentCompiler: webpack.Compiler
        ) => Promise<void>;
        • Parameter compilation

          The webpack compilation.

          Parameter parentCompiler

          The webpack parent compiler.

        method performChildCompilation

        performChildCompilation: (
        compilation: webpack.Compilation,
        parentCompiler: webpack.Compiler
        ) => Promise<void>;
        • Parameter compilation

          The webpack compilation.

          Parameter parentCompiler

          The webpack parent compiler.

        method propagateWebpackConfig

        propagateWebpackConfig: (compiler: webpack.Compiler) => void;
        • Parameter compiler

          default compiler object passed from webpack

        Interfaces

        interface GenerateSWConfig

        interface GenerateSWConfig extends WebpackGenerateSWOptions {}

          property manifestEntries

          manifestEntries?: Array<ManifestEntry>;

            Package Files (3)

            Dependencies (5)

            Dev Dependencies (2)

            Peer Dependencies (1)

            Badge

            To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

            You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/workbox-webpack-plugin.

            • Markdown
              [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/workbox-webpack-plugin)
            • HTML
              <a href="https://www.jsdocs.io/package/workbox-webpack-plugin"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>