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

Support for a workbox.config.js override file #5359

Open
jeffposnick opened this Issue Oct 8, 2018 · 8 comments

Comments

Projects
None yet
6 participants
@jeffposnick
Contributor

jeffposnick commented Oct 8, 2018

As per #5111 (comment), 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.

@Timer

This comment has been minimized.

Collaborator

Timer commented Oct 8, 2018

There's no prior art, but I'd love to see a solution that scales. We're on board with this configuration but would like to discuss its ergonomics first.

@mymattcarroll

This comment has been minimized.

mymattcarroll commented Oct 8, 2018

Are you set using a new external config file? Would you consider extending package.json. e.g.

{
  "name": "app",
  "version": "0.0.0",
  "react-scripts": {
    "workbox-webpack-plugin": {
      "skipWaiting": true
    }
  }
}
@Timer

This comment has been minimized.

Collaborator

Timer commented 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
  }
};
@Jeyloh

This comment has been minimized.

Jeyloh commented Oct 9, 2018

Would this simplify the process to add features like push eventlistener and cross origin images etc?

I'd be thrilled

@mymattcarroll

This comment has been minimized.

mymattcarroll commented Oct 9, 2018

@jeffposnick, @Timer I would be happy to contribute on this issue if it is open to contributors.

Would you prefer to have a workbox.config.js file catering for only overrides to the workbox-webpack-plugin or a react-app.config.js with an option for workbox-webpack-plugin configuration?

@frederikhors

This comment has been minimized.

frederikhors commented Oct 9, 2018

I'm in favor of adding a cra.config.js for these config and others, overriding default ones!

@jeffposnick

This comment has been minimized.

Contributor

jeffposnick commented Oct 9, 2018

Since there's interest from the community, I'm very happy to let others implement the actual code for this feature, and I could contribute relevant documentation once that's in place.

@bakasmarius

This comment has been minimized.

bakasmarius commented Oct 29, 2018

We need to configure CRA to build service-worker.js and precache-manifest.xxxxx.js inside build/static/js folder, and not directly inside build folder root as it is now.
This would result in almost not having to change our production nginx configuration.
So I guess the ability to have a cra.config.js file to owerride some Workbox options would do the trick.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment