Skip to content

Commit 008b5db

Browse files
vtenfyspieh
authored andcommitted
fix(gatsby-plugin-offline): prevent incorrect revisioning of static file by workbox (#10416)
1 parent 603ecea commit 008b5db

File tree

4 files changed

+6
-5
lines changed

4 files changed

+6
-5
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
/*.js
22
!index.js
3+
!sw-append.js
34
yarn.lock

packages/gatsby-plugin-offline/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,12 @@ const options = {
4040
cacheId: `gatsby-plugin-offline`,
4141
// Don't cache-bust JS or CSS files, and anything in the static directory,
4242
// since these files have unique URLs and their contents will never change
43-
dontCacheBustUrlsMatching: /(\.js$|\.css$|\/static\/)/,
43+
dontCacheBustUrlsMatching: /(\.js$|\.css$|static\/)/,
4444
runtimeCaching: [
4545
{
4646
// Use cacheFirst since these don't need to be revalidated (same RegExp
4747
// and same reason as above)
48-
urlPattern: /(\.js$|\.css$|\/static\/)/,
48+
urlPattern: /(\.js$|\.css$|static\/)/,
4949
handler: `cacheFirst`,
5050
},
5151
{

packages/gatsby-plugin-offline/src/gatsby-node.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,12 @@ exports.onPostBuild = (args, pluginOptions) => {
8282
cacheId: `gatsby-plugin-offline`,
8383
// Don't cache-bust JS or CSS files, and anything in the static directory,
8484
// since these files have unique URLs and their contents will never change
85-
dontCacheBustUrlsMatching: /(\.js$|\.css$|\/static\/)/,
85+
dontCacheBustUrlsMatching: /(\.js$|\.css$|static\/)/,
8686
runtimeCaching: [
8787
{
8888
// Use cacheFirst since these don't need to be revalidated (same RegExp
8989
// and same reason as above)
90-
urlPattern: /(\.js$|\.css$|\/static\/)/,
90+
urlPattern: /(\.js$|\.css$|static\/)/,
9191
handler: `cacheFirst`,
9292
},
9393
{
@@ -126,7 +126,7 @@ exports.onPostBuild = (args, pluginOptions) => {
126126
.readFileSync(`${__dirname}/sw-append.js`, `utf8`)
127127
.replace(/%pathPrefix%/g, pathPrefix)
128128

129-
fs.appendFileSync(`public/sw.js`, swAppend)
129+
fs.appendFileSync(`public/sw.js`, `\n` + swAppend)
130130
console.log(
131131
`Generated ${swDest}, which will precache ${count} files, totaling ${size} bytes.`
132132
)

0 commit comments

Comments
 (0)