generate-sw.d.ts 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import { BuildResult, GenerateSWOptions } from './types';
  2. /**
  3. * This method creates a list of URLs to precache, referred to as a "precache
  4. * manifest", based on the options you provide.
  5. *
  6. * It also takes in additional options that configures the service worker's
  7. * behavior, like any `runtimeCaching` rules it should use.
  8. *
  9. * Based on the precache manifest and the additional configuration, it writes
  10. * a ready-to-use service worker file to disk at `swDest`.
  11. *
  12. * ```
  13. * // The following lists some common options; see the rest of the documentation
  14. * // for the full set of options and defaults.
  15. * const {count, size, warnings} = await generateSW({
  16. * dontCacheBustURLsMatching: [new RegExp('...')],
  17. * globDirectory: '...',
  18. * globPatterns: ['...', '...'],
  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. * swDest: '...',
  42. * });
  43. * ```
  44. *
  45. * @memberof workbox-build
  46. */
  47. export declare function generateSW(config: GenerateSWOptions): Promise<BuildResult>;