UNPKG

2.47 kBJavaScriptView Raw
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
9module.exports = `/**
10 * Welcome to your Workbox-powered service worker!
11 *
12 * You'll need to register this file in your web app and you should
13 * disable HTTP caching for this file too.
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
22<% if (workboxSWImport) { %>
23importScripts(<%= JSON.stringify(workboxSWImport) %>);
24<% if (modulePathPrefix) { %>workbox.setConfig({modulePathPrefix: <%= JSON.stringify(modulePathPrefix) %>});<% } %>
25<% } %>
26<% if (importScripts) { %>
27importScripts(
28 <%= importScripts.map(JSON.stringify).join(',\\n ') %>
29);
30<% } %>
31
32<% if (cacheId) { %>workbox.core.setCacheNameDetails({prefix: <%= JSON.stringify(cacheId) %>});<% } %>
33
34<% if (skipWaiting) { %>workbox.core.skipWaiting();<% } %>
35<% if (clientsClaim) { %>workbox.core.clientsClaim();<% } %>
36
37<% if (Array.isArray(manifestEntries)) {%>
38/**
39 * The workboxSW.precacheAndRoute() method efficiently caches and responds to
40 * requests for URLs in the manifest.
41 * See https://goo.gl/S9QRab
42 */
43self.__precacheManifest = <%= JSON.stringify(manifestEntries, null, 2) %>.concat(self.__precacheManifest || []);
44workbox.precaching.precacheAndRoute(self.__precacheManifest, <%= precacheOptionsString %>);
45<% } else { %>
46if (Array.isArray(self.__precacheManifest)) {
47 workbox.precaching.precacheAndRoute(self.__precacheManifest, <%= precacheOptionsString %>);
48}
49<% } %>
50<% if (cleanupOutdatedCaches) { %>workbox.precaching.cleanupOutdatedCaches();<% } %>
51<% if (navigateFallback) { %>workbox.routing.registerNavigationRoute(workbox.precaching.getCacheKeyForURL(<%= JSON.stringify(navigateFallback) %>)<% if (navigateFallbackWhitelist || navigateFallbackBlacklist) { %>, {
52 <% if (navigateFallbackWhitelist) { %>whitelist: [<%= navigateFallbackWhitelist %>],<% } %>
53 <% if (navigateFallbackBlacklist) { %>blacklist: [<%= navigateFallbackBlacklist %>],<% } %>
54}<% } %>);<% } %>
55
56<% if (runtimeCaching) { runtimeCaching.forEach(runtimeCachingString => {%><%= runtimeCachingString %><% });} %>
57
58<% if (offlineAnalyticsConfigString) { %>workbox.googleAnalytics.initialize(<%= offlineAnalyticsConfigString %>);<% } %>`;