Last updated 2 years ago by Adam Laycockreact
If you found yourself on this page because you want to eject your Create React App project, the details you’re looking for are at the bottom of this article.
But before you jump down, I hope you consider reviewing this article because ejecting can introduce much more complexity to your project than you might anticipate. Before you commit to your irreversible decision to eject, let me propose a few alternatives.
There are 3 primary reasons why someone might choose to eject and each reason has either drawbacks or alternatives that should first be investigated.
I’ll admit that the first CRA project I created, I immediately ejected. My naïve assumption was that managing my own build process is something experts did and I assumed I was experienced enough to handle it.
“I’m a good programmer, I can manage my own build tools, I just need a headstart from Create-React-App.”
In reality, experts do everything they can to avoid additional configuration, tools, and code. Before you eject, ask yourself, “Do I want to build something using React or do I want to fight with picky build tools when things stop working?”
Don’t eject until you have a specific reason to do so. If you feel that you have a good reason to eject at a later date, circle back to this article and reevaluate your position. Ejecting is a one-way process and makes your configuration more complex; why burn that bridge before you’ve even used it?
If you’re being thoughtful enough to learn more about ejecting before jumping in, also be thoughtful enough to consider that CRA’s “sane defaults” might work for you, at least for now.
This is a great reason to eject. It’s the reason most people do so. However, before you eject, take the time to ensure you aren’t making extra work for yourself or repeating the work someone else has done previously.
There are thousands of issues filed in the Create-React-App repo, and chances are someone has already addressed your concern. Explore the existing discussions around the topic; you might find a solution or alternative already exists. If it hasn’t been discussed yet, consider filing an issue or making a PR. Thoughtful input is always appreciated.
A nice feature of the CRA sub-package react-scripts is that it can easily be forked and modified. The resulting forked configuration can then be used by your project. Try exploring some existing forks of react-scripts to see if they include the features you want, but without having the maintenance burden of managing your own configuration files. React-super-scripts is an example of one alternative that includes decorators, babel stage-0 features, CSS, SASS, and LESS modules: