Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What do you lose by ejecting a React app that was created using create-react-app?

I'm interested in using Hot Module Replacement with a newly created React app.

Facebook Incubator's create-react-app uses Webpack 2 which can be configured to support HMR, however in order to do so, one needs to "eject" the create-react-app project.

As the documentation points out, this is a "one way" operation and cannot be reversed.

If I'm to do this, I want to know what I might be giving up. I've been unable to locate any documentation that explains the potential drawbacks of ejecting.

like image 459
AndrewHenderson Avatar asked Mar 15 '17 18:03

AndrewHenderson


People also ask

What happens when you eject create react app?

The eject script gives you full control over the React app configuration. For example, you can customize the webpack or Babel configuration according to a specific need by ejecting the React app. Running the eject script will remove the single build dependency from your project.

What does npm eject do in react?

The last command, eject , is used to remove the dependency on react-scripts and expose the build tools and configurations for you to modify. All the configuration files from react-scripts will be copied into your project root's config/ folder, and the scripts to run the build will be copied into the scripts/ folder.

When should you eject from Create react app?

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?


1 Answers

The current configuration allows your project to get updates from create-react-app core team. Once you eject you no longer get this.

It's kind of like pulling in bootstrap css via CDN as opposed to downloading the source code and injecting it directly into your project.

If you want more control over your webpack, there are ways to configure/customize it without ejecting: https://www.npmjs.com/package/custom-react-scripts

like image 111
dwww Avatar answered Oct 03 '22 23:10

dwww