Proposal: expose webpack configuration as a package
See original GitHub issueProblem
We currently have two main options when using CRA:
Upate | Custom Config | |
---|---|---|
not eject | ✅ | ❌ |
eject | ❌ | ✅ |
There is a third option which is to maintain a fork of react-scripts
(like create-react-app-typescript does ). The downside here is that you have to merge all the changes made on create-react-app
and lerna make the whole things a bit messy in my opinion (because you have to fork all packages to publish only one of them).
Finally, there is a fourth option which consists of copying the scripts
folder in your app to edit the webpack config object before using it ( example repo here ).
But as pointed by @gaearon in this tweet, this solution is incompatible with semver and a minor update to react-scripts
could break your app because the configuration is locked down and could change at any moment.
Proposal
As a way to make the last solution more viable and safe, the proposal is to expose the webpack configuration object as a standalone package that would follow semver. This would allow to both extends the CRA config (with the method above) or use it in other contexts than CRA.
It might also be useful to expose the object as a webpack-chain object since it’s not always easy to edit a raw webpack config.
Thoughts ?
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:10 (4 by maintainers)
Top GitHub Comments
If we decide to support this, we might as well support overriding config in non-ejected projects. Because in practice people don’t really look at major versions of transitive dependencies. If they see direct modification of webpack config in one repo they’ll do it everywhere (and thus can misunderstand semver guarantees and get confused why their stuff breaks in patch releases).
Maybe now is a good time to start adding escape hatches that let you modify config? If it is, how do we communicate that you forgo semver guarantees once you do this?
I’m thinking something like
dangerouslyOverrideConfigs.js
in the root folder.@see vue-cli 3.0
https://github.com/vuejs/vue-cli/blob/dev/packages/%40vue/cli-service/package.json
webpack-chain
https://github.com/mozilla-neutrino/webpack-chain
support custom config
https://github.com/vuejs/vue-cli/blob/dev/docs/webpack.md