UNPKG

4.02 kBJavaScriptView Raw
1'use strict';
2
3/*
4 Copyright 2017 Google Inc.
5
6 Licensed under the Apache License, Version 2.0 (the "License");
7 you may not use this file except in compliance with the License.
8 You may obtain a copy of the License at
9
10 https://www.apache.org/licenses/LICENSE-2.0
11
12 Unless required by applicable law or agreed to in writing, software
13 distributed under the License is distributed on an "AS IS" BASIS,
14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 See the License for the specific language governing permissions and
16 limitations under the License.
17*/
18
19var copyWorkboxLibraries = require('./lib/copy-workbox-libraries');
20var generateSW = require('./entry-points/generate-sw');
21var generateSWString = require('./entry-points/generate-sw-string');
22var getManifest = require('./entry-points/get-manifest');
23var injectManifest = require('./entry-points/inject-manifest');
24
25var _require = require('./lib/cdn-utils'),
26 getModuleUrl = _require.getModuleUrl;
27
28/**
29 * This Node module can be used to generate a list of assets that should be
30 * precached in a service worker, generating a hash that can be used to
31 * intelligently update a cache when the service worker is updated.
32 *
33 * This module will use glob patterns to find assets in a given directory
34 * and use the resulting URL and revision data for one of the follow uses:
35 *
36 * 1. Generate a complete service worker with precaching and some basic
37 * configurable options, writing the resulting service worker file to disk. See
38 * [generateSW()]{@link module:workbox-build.generateSW}.
39 * 1. Generate a complete service worker with precaching and some basic
40 * configurable options, without writing the results to disk. See
41 * [generateSWString()]{@link module:workbox-build.generateSWString}.
42 * 1. Inject a manifest into an existing service worker. This allows you
43 * to control your own service worker while still taking advantage of
44 * [workboxSW.precache()]{@link module:workbox-sw.WorkboxSW#precache} logic.
45 * See [injectManifest()]{@link module:workbox-build.injectManifest}.
46 * 1. Just generate a manifest, not a full service worker file.
47 * This is useful if you want to make use of the manifest from your own existing
48 * service worker file and are okay with including the manifest yourself.
49 * See [getManifest()]{@link module:workbox-build.getManifest}.
50 *
51 * @property {Array<RegExp>} [ignoreUrlParametersMatching=[/^utm_/]] Any
52 * search parameter names that match against one of the regex's in this array
53 * will be removed before looking for a precache match.
54 *
55 * This is useful if your users might request URLs that contain, for example,
56 * URL parameters used to track the source of the traffic. Those URL parameters
57 * would normally cause the cache lookup to fail, since the URL strings used
58 * as cache keys would not be expected to include them.
59 *
60 * You can use `[/./]` to ignore all URL parameters.
61 *
62 * Note: This option is only valid when used with
63 * {@link module:workbox-build#generateSW|generateSW()}. When using
64 * {@link module:workbox-build.injectManifest|injectManifest()}, you can
65 * explicitly pass the desired value in to the
66 * {@link module:workbox-sw.WorkboxSW|WorkboxSW() constructor} in your `swSrc`
67 * file.
68 *
69 * E.g. `[/homescreen/]`
70 *
71 * @property {Boolean} [handleFetch=true] Whether or not `workbox-sw` should
72 * create a `fetch` event handler that responds to network requests. This is
73 * useful during development if you don't want the service worker serving stale
74 * content.
75 *
76 * Note: This option is only valid when used with
77 * {@link module:workbox-build#generateSW|generateSW()}. When using
78 * {@link module:workbox-build.injectManifest|injectManifest()}, you can
79 * explicitly pass the desired value in to the
80 * {@link module:workbox-sw.WorkboxSW|WorkboxSW() constructor} in your `swSrc`
81 * file.
82 *
83 * @module workbox-build
84 */
85
86
87module.exports = {
88 copyWorkboxLibraries,
89 generateSW,
90 generateSWString,
91 getManifest,
92 getModuleUrl,
93 injectManifest
94};
\No newline at end of file