mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-06 13:47:29 +02:00
* chore: upgrade ESLint related deps * Upgrade TS * Fix lock * Bump Babel * Update config
26 lines
732 B
JavaScript
26 lines
732 B
JavaScript
/**
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/
|
|
|
|
import {registerRoute} from 'workbox-routing';
|
|
import {StaleWhileRevalidate} from 'workbox-strategies';
|
|
|
|
export default function swCustom(params) {
|
|
if (params.debug) {
|
|
console.log('[Docusaurus-PWA][SW]: running swCustom code', params);
|
|
}
|
|
|
|
// Cache responses from external resources
|
|
registerRoute(
|
|
(context) =>
|
|
[
|
|
/graph\.facebook\.com\/.*\/picture/,
|
|
/netlify\.com\/img/,
|
|
/avatars1\.githubusercontent/,
|
|
].some((regex) => context.url.href.match(regex)),
|
|
new StaleWhileRevalidate(),
|
|
);
|
|
}
|