-
-
Notifications
You must be signed in to change notification settings - Fork 27k
Proposal: expose webpack configuration as a package #3786
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
Comments
What are some use cases for editing a config like this? |
I think most reason to
In my case I'm using this method to support a custom async module loader I've made (multiple entry points and setting In another project I've used this to add |
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 |
Um... right, |
Just to throw out a thought: I know that one of the reasons for keeping all the Webpack config locked away was the hypothetical idea that CRA might someday base its internals on another bundler instead. Is that still a meaningful concern? |
I think it's less likely today given that webpack has improved in many areas but we still prefer if most newly created apps don't immediately tie themselves to webpack-isms. |
Im using https://github.com/timarney/react-app-rewired in a big cra app which more ore less does the above except the config file is just called |
The way vue cli 3 does it is pretty cool |
Definitely vue cli v3 figured how to properly do this without that much trade off. |
Problem
We currently have two main options when using CRA:
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 oncreate-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 ?
The text was updated successfully, but these errors were encountered: