Hacker News new | ask | show | jobs
by ng12 2713 days ago
I just wish CRA would give me a hook to touch the webpack configs. I'm willing to bite the pain of needing to rewrite my custom configs if they move to something else.

Simple example: with webpack it's trivial to configure it to load env-specific extensions. You can have foo.js, foo.dev.js, and foo.mock.js and it will import the correct one automatically based on an env variable. It's three lines of code that I use in all my React projects and it's honestly enough to keep me away from CRA.

1 comments

The article covers the use-case of making small modifications to the build. react-app-rewired[1] and customize-cra[2] give you access to tweak the webpack build indirectly. While babel-macros[3] in CRA 2.X give you access to the babel transpilation step without having to eject. While it's not exactly what you're referring to, it does get you a little bit closer to the build.

[1] https://github.com/timarney/react-app-rewired/

[2] https://github.com/arackaf/customize-cra

[3] https://babeljs.io/blog/2017/09/11/zero-config-with-babel-ma...