4 ms·
I say this as someone who has been paid ridiculous amounts of money just to help configure and improve build systems: please just use CRA for all your React pro
by GeneralMaximus 7y ago
I say this as someone who has been paid ridiculous amounts of money just to help configure and improve build systems: please just use CRA for all your React projects. Or, if you need server-side rendering, use Next.js. There are, like, five people in the world who have any business manually configuring Webpack+Babel+SASS+TypeScript+$WHATEVER, and all of those people are already working on CRA.
Modern frontend build tooling is complex, and getting it right in a way that it's (a) correct, (b) maintainable, (c) extensible, and (d) upgradeable is ridiculously hard.
You'll make mistakes that will cause your bundles to balloon in size, or produce assets you never asked for, or fail to produce assets you really needed. You'll be asked to add features to the system that will require full refactors of everything because you didn't think of extensibility upfront. You'll accidentally use libraries that end up being abandoned, or those that break compatibility. You'll want to upgrade to new versions of a single tool, but you'll be stuck in dependency hell where upgrading TypeScript will require a new version of Babel, which will require a new version of Webpack, which will require new versions of seventeen random libraries, and now you're spending your entire week fixing the build instead of writing features.
I know CRA has more features than a lot of people need. But deal with the white noise (and a few extra megabytes of node_modules) and just use it without ejecting. A huge team of smart people is already doing all the dirty work of making sure builds work as expected so you can concentrate on features. Please just use their work.
- awongh 7y agoI've been finding that I go outside the base config quite quickly. I wanted to compile a second app with different babel settings and have that in my webpack config. I gave up on it after a few hours of trying to figure out what I would need. Is this really a super rare case that only experts should attempt? When I ejected CRA it gave me a 600 line config file. I think I also find the general attitude of the community ("it's all modular!") to be disingenuous. Just bundle all this stuff into a monoremp massive npm package and be done with it, ala rails.
- chrisweekly 7y agoI think CRA does an amazingly good job for the standard non-ejected scenario. Ejecting and hacking on the output is educational, but rarely a good idea. Which is fine. My chief complaint is the lack of robust, non-ejection extensibility. Projects like CRACO, and babel macros, IMHO should be standard and officially supported.
- nicoburns 7y ago> When I ejected CRA it gave me a 600 line config file. This is one of my least favourite thing about CRA. The equivalent Webpack config tailored to the needs of my project is generally only 100-200 lines long. CRA makes things far more complicated than it needs to be because it has to support everyone's requirements.
- jakelazaroff 7y agoOut of curiosity, what do you end up needing that's not supported by default by CRA (or Next or Gatsby)? I've started a bunch of apps with CRA, and not once have I needed anything that's not already there.
- codingdave 7y ago> There are, like, five people in the world who have any business manually configuring Webpack+Babel+SASS+TypeScript+$WHATEVER, and all of those people are already working on CRA. I didn't find manual configuration of all that to be all that difficult to learn. I feel like people get a ton of use from CRA when learning, and then are told never to touch the magic black box of CRA because it is just so hard. So they never do. And never realize that it isn't as bad as all that. I do think it provides a great service for new coders, or small projects. So I do recommend using it in many cases. But I completely reject the idea that only 5 people in world are smart enough to set up their own build configs.
- filleduchaos 7y ago> But I completely reject the idea that only 5 people in world are smart enough to set up their own build configs. There's a rather irritating tendency to frankly insult the intelligence of anyone that's not working on $BIG_NAME_PACKAGE, as though the people working on these libraries are from outer space and not (most often) rather regular humans who've ended up on particular career paths due to planning and/or being strategically positioned at the right time. For some reason it's particularly prevalent in the JS community, where it especially does not make any sense considering that it's a very active open-source scene with plenty of people pointing out bugs and submitting fixes to popular packages every day. I wonder if it's a frontend web dev thing in general - it's common to see people make similarly hyperbolic statements about CSS (no, it's not that hard to centre a div, and even if it was it says more about you if you agonise over it every time you encounter it and not just, I don't know, save the working snippet somewhere and refer to it when you need it).
- GeneralMaximus 7y ago> There's a rather irritating tendency to frankly insult the intelligence of anyone that's not working on $BIG_NAME_PACKAGE [...] I apologize if what I said came across like that. I don't mean to insult the intelligence of people who want to roll their own build tooling, I just want to point out that doing so is a waste of time when somebody else has put in the work of building doing that for you. I would say the same thing to someone who wanted to build their own web framework instead of just using Rails/Django, or someone who wanted to build their own blog engine instead of using WordPress/Jekyll. Your time is valuable. Don't waste it on writing Webpack configs. Of course, if you're doing any of this to learn how things work, then more power to you! But if you're putting hand-rolled versions of popular frameworks and libraries in production, then you're doing a disservice to those who have to maintain those things after you've left your job. I can say with confidence that most posters on HN (including myself) will do a worse job at setting up a build system than CRA. There are hundreds of contributors fixing issues in CRA, and all of them are really smart people. It's an open-source project with thousands of eyes looking at the code. I doubt that a lone developer working in a silo could come up with something better.