Skip to content

Commit 8cd7432

Browse files
ubergesundheitpieh
authored andcommitted
fix(gatsby-plugin-offline): Sync docs with actual defaults being used (#9903)
I've noticed the Readme of gatsby-plugin-offline is out of sync with the actual defaults from its gatsby-node.js. This commit fixes this by copying the options object from gatsby/packages/gatsby-plugin-offline/src/gatsby-node.js into this Readme.
1 parent 3005954 commit 8cd7432

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

packages/gatsby-plugin-offline/README.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,11 @@ const options = {
3333
globDirectory: rootDir,
3434
globPatterns,
3535
modifyUrlPrefix: {
36-
rootDir: ``,
3736
// If `pathPrefix` is configured by user, we should replace
3837
// the default prefix with `pathPrefix`.
39-
"": args.pathPrefix || ``,
38+
"/": `${pathPrefix}/`,
4039
},
41-
navigateFallback: `/offline-plugin-app-shell-fallback/index.html`,
40+
navigateFallback: `${pathPrefix}/offline-plugin-app-shell-fallback/index.html`,
4241
// Only match URLs without extensions or the query `no-cache=1`.
4342
// So example.com/about/ will pass but
4443
// example.com/about/?no-cache=1 and
@@ -47,17 +46,22 @@ const options = {
4746
// URLs and not any files hosted on the site.
4847
//
4948
// Regex based on http://stackoverflow.com/a/18017805
50-
navigateFallbackWhitelist: [/^[^?]*([^.?]{5}|\.html)(\?.*)?$/],
49+
navigateFallbackWhitelist: [/^([^.?]*|[^?]*\.([^.?]{5,}|html))(\?.*)?$/],
5150
navigateFallbackBlacklist: [/\?(.+&)?no-cache=1$/],
5251
cacheId: `gatsby-plugin-offline`,
53-
// Don't cache-bust JS files and anything in the static directory
54-
dontCacheBustUrlsMatching: /(.*js$|\/static\/)/,
52+
// Don't cache-bust JS or CSS files, and anything in the static directory
53+
dontCacheBustUrlsMatching: /(.*\.js$|.*\.css$|\/static\/)/,
5554
runtimeCaching: [
5655
{
5756
// Add runtime caching of various page resources.
5857
urlPattern: /\.(?:png|jpg|jpeg|webp|svg|gif|tiff|js|woff|woff2|json|css)$/,
5958
handler: `staleWhileRevalidate`,
6059
},
60+
{
61+
// Use the Network First handler for external resources
62+
urlPattern: /^https?:/,
63+
handler: `networkFirst`,
64+
},
6165
],
6266
skipWaiting: true,
6367
clientsClaim: true,

0 commit comments

Comments
 (0)