Skip to content

Commit

Permalink
fix(gatsby-plugin-offline): prevent incorrect revisioning of static f…
Browse files Browse the repository at this point in the history
…ile by workbox (gatsbyjs#10416)
  • Loading branch information
vtenfys authored and gpetrioli committed Jan 22, 2019
1 parent 20b6044 commit 57b82b6
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions packages/gatsby-plugin-offline/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/*.js
!index.js
!sw-append.js
yarn.lock
4 changes: 2 additions & 2 deletions packages/gatsby-plugin-offline/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ const options = {
cacheId: `gatsby-plugin-offline`,
// Don't cache-bust JS or CSS files, and anything in the static directory,
// since these files have unique URLs and their contents will never change
dontCacheBustUrlsMatching: /(\.js$|\.css$|\/static\/)/,
dontCacheBustUrlsMatching: /(\.js$|\.css$|static\/)/,
runtimeCaching: [
{
// Use cacheFirst since these don't need to be revalidated (same RegExp
// and same reason as above)
urlPattern: /(\.js$|\.css$|\/static\/)/,
urlPattern: /(\.js$|\.css$|static\/)/,
handler: `cacheFirst`,
},
{
Expand Down
6 changes: 3 additions & 3 deletions packages/gatsby-plugin-offline/src/gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,12 @@ exports.onPostBuild = (args, pluginOptions) => {
cacheId: `gatsby-plugin-offline`,
// Don't cache-bust JS or CSS files, and anything in the static directory,
// since these files have unique URLs and their contents will never change
dontCacheBustUrlsMatching: /(\.js$|\.css$|\/static\/)/,
dontCacheBustUrlsMatching: /(\.js$|\.css$|static\/)/,
runtimeCaching: [
{
// Use cacheFirst since these don't need to be revalidated (same RegExp
// and same reason as above)
urlPattern: /(\.js$|\.css$|\/static\/)/,
urlPattern: /(\.js$|\.css$|static\/)/,
handler: `cacheFirst`,
},
{
Expand Down Expand Up @@ -126,7 +126,7 @@ exports.onPostBuild = (args, pluginOptions) => {
.readFileSync(`${__dirname}/sw-append.js`, `utf8`)
.replace(/%pathPrefix%/g, pathPrefix)

fs.appendFileSync(`public/sw.js`, swAppend)
fs.appendFileSync(`public/sw.js`, `\n` + swAppend)
console.log(
`Generated ${swDest}, which will precache ${count} files, totaling ${size} bytes.`
)
Expand Down
File renamed without changes.

0 comments on commit 57b82b6

Please sign in to comment.