sw-template.js 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. "use strict";
  2. /*
  3. Copyright 2018 Google LLC
  4. Use of this source code is governed by an MIT-style
  5. license that can be found in the LICENSE file or at
  6. https://opensource.org/licenses/MIT.
  7. */
  8. Object.defineProperty(exports, "__esModule", { value: true });
  9. exports.swTemplate = void 0;
  10. exports.swTemplate = `/**
  11. * Welcome to your Workbox-powered service worker!
  12. *
  13. * You'll need to register this file in your web app.
  14. * See https://goo.gl/nhQhGp
  15. *
  16. * The rest of the code is auto-generated. Please don't update this file
  17. * directly; instead, make changes to your Workbox build configuration
  18. * and re-run your build process.
  19. * See https://goo.gl/2aRDsh
  20. */
  21. <% if (importScripts) { %>
  22. importScripts(
  23. <%= importScripts.map(JSON.stringify).join(',\\n ') %>
  24. );
  25. <% } %>
  26. <% if (navigationPreload) { %><%= use('workbox-navigation-preload', 'enable') %>();<% } %>
  27. <% if (cacheId) { %><%= use('workbox-core', 'setCacheNameDetails') %>({prefix: <%= JSON.stringify(cacheId) %>});<% } %>
  28. <% if (skipWaiting) { %>
  29. self.skipWaiting();
  30. <% } else { %>
  31. self.addEventListener('message', (event) => {
  32. if (event.data && event.data.type === 'SKIP_WAITING') {
  33. self.skipWaiting();
  34. }
  35. });
  36. <% } %>
  37. <% if (clientsClaim) { %><%= use('workbox-core', 'clientsClaim') %>();<% } %>
  38. <% if (Array.isArray(manifestEntries) && manifestEntries.length > 0) {%>
  39. /**
  40. * The precacheAndRoute() method efficiently caches and responds to
  41. * requests for URLs in the manifest.
  42. * See https://goo.gl/S9QRab
  43. */
  44. <%= use('workbox-precaching', 'precacheAndRoute') %>(<%= JSON.stringify(manifestEntries, null, 2) %>, <%= precacheOptionsString %>);
  45. <% if (cleanupOutdatedCaches) { %><%= use('workbox-precaching', 'cleanupOutdatedCaches') %>();<% } %>
  46. <% if (navigateFallback) { %><%= use('workbox-routing', 'registerRoute') %>(new <%= use('workbox-routing', 'NavigationRoute') %>(<%= use('workbox-precaching', 'createHandlerBoundToURL') %>(<%= JSON.stringify(navigateFallback) %>)<% if (navigateFallbackAllowlist || navigateFallbackDenylist) { %>, {
  47. <% if (navigateFallbackAllowlist) { %>allowlist: [<%= navigateFallbackAllowlist %>],<% } %>
  48. <% if (navigateFallbackDenylist) { %>denylist: [<%= navigateFallbackDenylist %>],<% } %>
  49. }<% } %>));<% } %>
  50. <% } %>
  51. <% if (runtimeCaching) { runtimeCaching.forEach(runtimeCachingString => {%><%= runtimeCachingString %><% });} %>
  52. <% if (offlineAnalyticsConfigString) { %><%= use('workbox-google-analytics', 'initialize') %>(<%= offlineAnalyticsConfigString %>);<% } %>
  53. <% if (disableDevLogs) { %>self.__WB_DISABLE_DEV_LOGS = true;<% } %>`;