Skip to content

Commit

Permalink
feat(gatsby-plugin-offline): Merge workboxConfig and default o… (#19437)
Browse files Browse the repository at this point in the history
  • Loading branch information
trevorblades authored and sidharthachatterjee committed Nov 12, 2019
1 parent 0fc9534 commit 8791329
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions packages/gatsby-plugin-offline/src/gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,7 @@ exports.onPostBuild = (
clientsClaim: true,
}

const combinedOptions = {
...options,
...workboxConfig,
}
const combinedOptions = _.merge(options, workboxConfig)

const idbKeyvalFile = `idb-keyval-iife.min.js`
const idbKeyvalSource = require.resolve(`idb-keyval/dist/${idbKeyvalFile}`)
Expand Down

1 comment on commit 8791329

@zaycker
Copy link

@zaycker zaycker commented on 8791329 Feb 3, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like breaking change, especially for runtimeCaching value. In case of spread operator runtimeCaching value will completely redefine default one while _.merge() will do a recursive merge.
With _.merge to change, for example, the second rule of runtimeCaching for the page-data.json strategy you need to define in the config such structure:

workboxConfig: {
  runtimeCaching: [
    {},
    {
      // page-data.json files are not content hashed
      urlPattern: /^https?:.*\page-data\/.*\/page-data\.json/,
      handler: 'NetworkFirst',
    },
  ],
}

not obvious...

Please sign in to comment.