Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When do you eject a reactjs application

Tags:

reactjs

I have built a reactJS application npx create-react-app.

Currently I have ejected the application because I need to use the copy webpack plugin. For that, I need to get access to the configuration files.

The question is,

  • Is it a good practice to eject the application?
  • Will there be any any issue because of this?
  • Under what circumstances do you run "npm run eject"
like image 801
prajeesh Avatar asked Feb 11 '19 11:02

prajeesh


People also ask

What is the use of eject in react app?

:) eject: is an advanced operation it allows you to customize the configuration under Create-React-App (react-scripts) Before do eject you need to understand the consequences: it is a one-way operation!

Should you eject react from your project?

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.

What happens when you run NPM run eject in react?

When you run npm run eject command in your React application, you will be able to edit the configuration and script files. You also can upgrade or downgrade the dependencies version on the ejected package.json file. But the eject command comes with a price. Once you eject, you can’t go back and hide the configuration files.

Where can I find the react-scripts code when ejecting?

When ejecting, you will gain access to the code from the react-scripts package. The same code can also be found on the CRA Github repo if you want to do some exploration before ejecting. The CRA repo also contains several other packages which you might also find interesting to investigate.


1 Answers

  • There is no real recommended practice for this. If you feel the need to override your configurations, then do it. Otherwise, there's no reason to do so.

  • There will be no harmful effects from ejecting. Your build is simply going from being wrapped in a single dependency to its actual component parts.

  • Usually you would run eject when you want to override something in the configuration. For example if you want to use your copy-webpack-plugin. Or want to use custom aliases. Or any other plugin/function/tweak to your configurations

like image 59
ManavM Avatar answered Oct 12 '22 01:10

ManavM