generate-sw.d.ts 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. import webpack from 'webpack';
  2. import { ManifestEntry, WebpackGenerateSWOptions } from 'workbox-build';
  3. export interface GenerateSWConfig extends WebpackGenerateSWOptions {
  4. manifestEntries?: Array<ManifestEntry>;
  5. }
  6. /**
  7. * This class supports creating a new, ready-to-use service worker file as
  8. * part of the webpack compilation process.
  9. *
  10. * Use an instance of `GenerateSW` in the
  11. * [`plugins` array](https://webpack.js.org/concepts/plugins/#usage) of a
  12. * webpack config.
  13. *
  14. * ```
  15. * // The following lists some common options; see the rest of the documentation
  16. * // for the full set of options and defaults.
  17. * new GenerateSW({
  18. * exclude: [/.../, '...'],
  19. * maximumFileSizeToCacheInBytes: ...,
  20. * navigateFallback: '...',
  21. * runtimeCaching: [{
  22. * // Routing via a matchCallback function:
  23. * urlPattern: ({request, url}) => ...,
  24. * handler: '...',
  25. * options: {
  26. * cacheName: '...',
  27. * expiration: {
  28. * maxEntries: ...,
  29. * },
  30. * },
  31. * }, {
  32. * // Routing via a RegExp:
  33. * urlPattern: new RegExp('...'),
  34. * handler: '...',
  35. * options: {
  36. * cacheName: '...',
  37. * plugins: [..., ...],
  38. * },
  39. * }],
  40. * skipWaiting: ...,
  41. * });
  42. * ```
  43. *
  44. * @memberof module:workbox-webpack-plugin
  45. */
  46. declare class GenerateSW {
  47. protected config: GenerateSWConfig;
  48. private alreadyCalled;
  49. /**
  50. * Creates an instance of GenerateSW.
  51. */
  52. constructor(config?: GenerateSWConfig);
  53. /**
  54. * @param {Object} [compiler] default compiler object passed from webpack
  55. *
  56. * @private
  57. */
  58. propagateWebpackConfig(compiler: webpack.Compiler): void;
  59. /**
  60. * @param {Object} [compiler] default compiler object passed from webpack
  61. *
  62. * @private
  63. */
  64. apply(compiler: webpack.Compiler): void;
  65. /**
  66. * @param {Object} compilation The webpack compilation.
  67. *
  68. * @private
  69. */
  70. addAssets(compilation: webpack.Compilation): Promise<void>;
  71. }
  72. export { GenerateSW };