question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support for a workbox.config.js override file

See original GitHub issue

As per https://github.com/facebook/create-react-app/pull/5111#issuecomment-425458687, there was discussion around the c-r-a v2 timeframe for allowing developers to override the default workbox-webpack-plugin (i.e. service worker generation) configuration with their own external workbox.config.js file. This functionality did not end up making it into the final release, though.

I’d love to see that happen, as putting together a one-size-fits-all default config can leave some developers confused.

I’m happy to submit a PR for that and update the docs accordingly, but I wanted to see if there was any prior art around external, user-controllable configuration files that did make it into the c-r-a v2 release. I’d rather just use a similar approach for Workbox if that solution for another plugin already exists.

If there is no prior art for configuring other plugins in v2, I’d like to confirm that folks like @gaearon and @Timer are fully on board with the idea of external config files, since it’s been a contentious point in the past.

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:118
  • Comments:13 (4 by maintainers)

github_iconTop GitHub Comments

39reactions
Timercommented, Oct 8, 2018

I think we’d rather use a file. e.g.

// react-app.config.js
module.exports = {
  workbox(options) {
    // should options be frozen?
    return options
  }
};
24reactions
iansucommented, Apr 16, 2019

#5369 adds a workbox.config.js file.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Precaching in Create React App with Workbox - web.dev
This would allow developers to override the default settings by just creating a single workbox.config.js file. For more details on all the ...
Read more >
Using Workbox with Create React App (Without Ejecting)
Step 2— Create config-overrides.js file. Create a file in the root of your project called config-overrides.js and add this code:.
Read more >
Add more service-worker functionality with create-react-app
Wonder if I can use something like "build": "react-scripts build && workbox-cli generate:sw --config-file=workbox-config.js" to override the ...
Read more >
workbox - PWA Module - GitBook
You can pass options to pwa.workbox in nuxt.config.js to override the defaults. ... (Array) Cache a set of files when registering service worker....
Read more >
The ways of Workbox - Chrome Developers
In this workflow, the source service worker file needs to have a ... a workbox-config.js file that you can customize to suit your...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found