mirror of
https://github.com/facebook/docusaurus.git
synced 2025-07-17 16:47:56 +02:00
* implement PWA plugin * added pwa support for docusaurus website * moved sw registration to client module * moved compile function to webpack util * build sw using webpack and render pwa popup * implement @theme/PwaReloadPopup * update website sw to use modules * updated pwa readme * fix header lint errors * apply code formatting * cache files only for mobile, saveData, or installed pwa * added comments about clearing registrations * fixed prettier error * updated pwa README * fix README JS * move /blog => /blog/index.html logic to else branch * add `alwaysPrecache` option * updated docusaurus-plugin-pwa version * added pwa to using-plugins.md * review fixes * re-disable restricted-globals to use self in service worker * useless doc * Update packages/docusaurus-plugin-pwa/README.md Co-authored-by: Reece Dunham <me@rdil.rocks> * Update packages/docusaurus-plugin-pwa/README.md * update a bit pwa doc + minor refactors * minor refactors + add workbox debug mode * env PWA_ prefix * typo * minor refactor * fix file output * add serve:v2:ssl yarn command * minor pwa fixes * typo * add dynamic import comment in SW * comment * let the PWA plugin implement its reload popup on his own * pwa: add Joi options validation * pwa plugin should have its own webpack/babel custom setup * PWA: - debug logs - better SW params system - offline mode activation strategies - docs * add pwa install gif * pwa: popup -> reloadPopup + minor refactors * fix process.env reading + better debug log * minor fixes * minor changes * minor changes Co-authored-by: slorber <lorber.sebastien@gmail.com> Co-authored-by: Sébastien Lorber <slorber@users.noreply.github.com> Co-authored-by: Reece Dunham <me@rdil.rocks>
24 lines
723 B
JavaScript
24 lines
723 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) => {
|
|
return [
|
|
/graph\.facebook\.com\/.*\/picture/,
|
|
/netlify\.com\/img/,
|
|
/avatars1\.githubusercontent/,
|
|
].some((regex) => context.url.href.match(regex));
|
|
}, new StaleWhileRevalidate());
|
|
}
|