Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(gatsby-plugin-offline): Remove slash from /static + move sw-append out of src #10416

Merged
merged 3 commits into from
Dec 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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