Craco generated config API
See original GitHub issueHave you considered exposing an API that will return the merged config for the various portions of the react-scripts
build process? That way people can use them in other places of their app and remain in sync with their actual build process.
The reason I ask is because I use vscode-jest
, which I really like because it runs your tests in real time. However, it doesn’t know how to use react-scripts
jest config, so you have to tell it how. I did that by creating my own jest.config.js
. I wanted it to run the exact same way that it would if I run craco test
, though, and I didn’t want to reinvent the wheel. I also wanted to reduce the time I would have to spend maintaining configurations for craco
and for vscode-jest
So, I wound up digging through craco
and react-scripts
to find what I needed, and put it all together so that the end result would be my craco
generated react-scripts
jest config. You can see the working product here:
https://gist.github.com/Js-Brecht/84ad06ac851af23ea84829fac4dd4fe2
As you can see, it starts out as basically a copy of test.js
, then kind of pretends to be react-scripts
.
Configured this way, I can make changes in one place, craco.config.js
, and see the results in vscode immediately. The behavior is also identical between live & build processes. It’s great.
BUT, I am pretty much locked into one version of both react-scripts
, and craco
. If I upgrade, I would then have to spend time maintaining this config, to keep it up to date with the two repositories. I’m essentially banking on those processes not changing much in the future.
It would be great to just call a function from craco
to get the generated configuration, and use that. Then, if I wanted to add some functionality that’s separate from the build process, I could do that, too; plus I wouldn’t have to hook into modules that are probably supposed to be internal 😕
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (3 by maintainers)
Top GitHub Comments
It works great! Much simpler 🙂. I don’t have occasion to use the Webpack API, but I can confirm that the Jest API works.
Hi @Js-Brecht
The API is available with 5.3.
Documentation is available here.
I would love to have your feedback!
Patrick