From 52d6a73f73bca5ca957f2d5b67f88d4407b8131c Mon Sep 17 00:00:00 2001 From: "Q.Tran" Date: Thu, 3 Dec 2020 01:27:43 +0700 Subject: [PATCH 1/2] eedit gatsby plugin offline --- gatsby-config.js | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/gatsby-config.js b/gatsby-config.js index 8edf3b3..1c7775f 100644 --- a/gatsby-config.js +++ b/gatsby-config.js @@ -189,7 +189,36 @@ module.exports = { icon: 'static/photo.jpg' }, }, - 'gatsby-plugin-offline', + { + resolve: 'gatsby-plugin-offline', + options: { + workboxConfig: { + runtimeCaching: [{ + // Use cacheFirst since these don't need to be revalidated (same RegExp + // and same reason as above) + urlPattern: /(\.js$|\.css$|[^:]static\/)/, + handler: `CacheFirst`, + }, + { + // page-data.json files, static query results and app-data.json + // are not content hashed + urlPattern: /^https?:.*\/page-data\/.*\.json/, + handler: `StaleWhileRevalidate`, + }, + { + // Add runtime caching of various other page resources + urlPattern: /^https?:.*\.(png|jpg|jpeg|webp|svg|gif|tiff|js|woff|woff2|json|css)$/, + handler: `StaleWhileRevalidate`, + }, + { + // Google Fonts CSS (doesn't end in .css so we need to specify it) + urlPattern: /^https?:\/\/fonts\.googleapis\.com\/css/, + handler: `StaleWhileRevalidate`, + }, + ], + }, + }, + }, 'gatsby-plugin-catch-links', 'gatsby-plugin-react-helmet', { From 92463f182e74bc68f32f13012241dbe96fd7a31e Mon Sep 17 00:00:00 2001 From: "Q.Tran" Date: Thu, 3 Dec 2020 01:38:24 +0700 Subject: [PATCH 2/2] update lint --- gatsby-config.js | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/gatsby-config.js b/gatsby-config.js index 1c7775f..093da5d 100644 --- a/gatsby-config.js +++ b/gatsby-config.js @@ -194,27 +194,27 @@ module.exports = { options: { workboxConfig: { runtimeCaching: [{ - // Use cacheFirst since these don't need to be revalidated (same RegExp - // and same reason as above) - urlPattern: /(\.js$|\.css$|[^:]static\/)/, - handler: `CacheFirst`, - }, - { - // page-data.json files, static query results and app-data.json - // are not content hashed - urlPattern: /^https?:.*\/page-data\/.*\.json/, - handler: `StaleWhileRevalidate`, - }, - { - // Add runtime caching of various other page resources - urlPattern: /^https?:.*\.(png|jpg|jpeg|webp|svg|gif|tiff|js|woff|woff2|json|css)$/, - handler: `StaleWhileRevalidate`, - }, - { - // Google Fonts CSS (doesn't end in .css so we need to specify it) - urlPattern: /^https?:\/\/fonts\.googleapis\.com\/css/, - handler: `StaleWhileRevalidate`, - }, + // Use cacheFirst since these don't need to be revalidated (same RegExp + // and same reason as above) + urlPattern: /(\.js$|\.css$|[^:]static\/)/, + handler: 'CacheFirst', + }, + { + // page-data.json files, static query results and app-data.json + // are not content hashed + urlPattern: /^https?:.*\/page-data\/.*\.json/, + handler: 'StaleWhileRevalidate', + }, + { + // Add runtime caching of various other page resources + urlPattern: /^https?:.*\.(png|jpg|jpeg|webp|svg|gif|tiff|js|woff|woff2|json|css)$/, + handler: 'StaleWhileRevalidate', + }, + { + // Google Fonts CSS (doesn't end in .css so we need to specify it) + urlPattern: /^https?:\/\/fonts\.googleapis\.com\/css/, + handler: 'StaleWhileRevalidate', + }, ], }, },