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