precacheAndRoute.mjs 910 B

12345678910111213141516171819202122232425262728293031
  1. /*
  2. Copyright 2019 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 {addRoute} from './addRoute.mjs';
  8. import {precache} from './precache.mjs';
  9. import './_version.mjs';
  10. /**
  11. * This method will add entries to the precache list and add a route to
  12. * respond to fetch events.
  13. *
  14. * This is a convenience method that will call
  15. * [precache()]{@link module:workbox-precaching.precache} and
  16. * [addRoute()]{@link module:workbox-precaching.addRoute} in a single call.
  17. *
  18. * @param {Array<Object|string>} entries Array of entries to precache.
  19. * @param {Object} options See
  20. * [addRoute() options]{@link module:workbox-precaching.addRoute}.
  21. *
  22. * @alias workbox.precaching.precacheAndRoute
  23. */
  24. export const precacheAndRoute = (entries, options) => {
  25. precache(entries);
  26. addRoute(options);
  27. };