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.

Proposal: expose webpack configuration as a package

See original GitHub issue

Problem

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:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

14reactions
gaearoncommented, Jan 14, 2018

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Authoring Libraries | webpack
In the above example, we're telling webpack to bundle src/index.js into dist/webpack-numbers.js . Expose the Library. So far everything should be the same ......
Read more >
Package exports - webpack
The exports field in the package.json of a package allows to declare which module should be used when using module requests like import...
Read more >
Configuration - webpack
webpack is a module bundler. Its main purpose is to bundle JavaScript files for usage in a browser, yet it is also capable...
Read more >
Entry Points - webpack
We will show you the ways you can configure the entry property, in addition to explaining why it may be useful to you....
Read more >
Experiments | webpack
webpack is a module bundler. Its main purpose is to bundle JavaScript files for usage in a browser, yet it is also capable...
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