2 ms·
Yes, that's what happens if you eject. But the point is that ejecting is an absolute last-ditch option that almost no one should have to resort to. Most folks
by acemarke 7y ago
Yes, that's what happens if you eject. But the point is that ejecting is an absolute last-ditch option that almost no one should have to resort to.
Most folks won't need to customize the standard CRA behavior. If you do, there's the community override tools.
As a specific example, two years ago I wrote a tutorial on how to use the Cesium 3D globe library with Webpack [0]. Loading Cesium at the time required changing two Webpack config options, so my tutorial started with "create a CRA app, then eject".
I recently set up a brand new CRA project that also uses Cesium. I could have used `craco` or a similar override tool to apply those Webpack config tweaks myself, but there's actually a `craco-cesium` plugin [1] that applies those edits and handles copying Cesium's assets to the CRA build output folder. This new project didn't have to eject at all.
As another example, that same project also needed to do more customization to the dev server proxying setup than CRA normally allows. CRA lets you define a simple `"proxy"` option in `package.json`, or a `setupProxy.js` file that gets a reference to the Express app to add middleware. I actually needed to apply a proxy middleware at the _end_ of the chain. `craco` let me access the actual Webpack config setup to do that [2].
The other nice thing about these override tools is that your modifications are isolated in one place, so you know exactly what changes are being made. If I were to eject and get all those config files in my project, yeah, I wouldn't know what had been edited from the originals without digging into the Git history. This way, it's one `configOverrides.js` file at most, and I get all the benefits of the rest of CRA's config which has had thousands of man-hours put into it.
[0] https://blog.isquaredsoftware.com/2017/03/declarative-earth-part-1-cesium-webpack/ https://blog.isquaredsoftware.com/2017/03/declarative-earth-...
[1] https://github.com/darwin-education/craco-cesium https://github.com/darwin-education/craco-cesium
[2] https://twitter.com/acemarke/status/1152371310682607618 https://twitter.com/acemarke/status/1152371310682607618