get-manifest.ts 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. /*
  2. Copyright 2018 Google LLC
  3. Use of this source code is governed by an MIT-style
  4. license that can be found in the LICENSE file or at
  5. https://opensource.org/licenses/MIT.
  6. */
  7. import {getFileManifestEntries} from './lib/get-file-manifest-entries';
  8. import {GetManifestOptions, GetManifestResult} from './types';
  9. import {validateGetManifestOptions} from './lib/validate-options';
  10. /**
  11. * This method returns a list of URLs to precache, referred to as a "precache
  12. * manifest", along with details about the number of entries and their size,
  13. * based on the options you provide.
  14. *
  15. * ```
  16. * // The following lists some common options; see the rest of the documentation
  17. * // for the full set of options and defaults.
  18. * const {count, manifestEntries, size, warnings} = await getManifest({
  19. * dontCacheBustURLsMatching: [new RegExp('...')],
  20. * globDirectory: '...',
  21. * globPatterns: ['...', '...'],
  22. * maximumFileSizeToCacheInBytes: ...,
  23. * });
  24. * ```
  25. *
  26. * @memberof workbox-build
  27. */
  28. export async function getManifest(
  29. config: GetManifestOptions,
  30. ): Promise<GetManifestResult> {
  31. const options = validateGetManifestOptions(config);
  32. return await getFileManifestEntries(options);
  33. }