Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 

94 строки
3.9 KiB

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