Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the purpose of ng eject?

The documentation is very brief with this topic:

ng eject ejects your app and output the proper webpack configuration and scripts

What is the purpose of this command?

like image 218
John-Philip Avatar asked May 22 '17 10:05

John-Philip


People also ask

What is webpack config js in angular?

Webpack is a popular module bundler, a tool for bundling application source code in convenient chunks and for loading that code from a server into a browser. It's an excellent alternative to the SystemJS approach used elsewhere in the documentation.

What is webpack eject?

If you aren't satisfied with the build tool and configuration choices, you can eject at any time. This command will remove the single build dependency from your project. Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc.)

What is NGX build plus?

Extend the Angular CLI's default build behavior without ejecting: 📄 Extend the default behavior by providing a partial config that just contains your additional settings. 📄 Alternative: Extend the default behavior by providing a custom function.


2 Answers

angular-cli is something magic, everything is done in a simple and automatic way.

But sometimes, you may want to act on how the package is done, add a plugin or you are simply curious to see the Webpack configuration on which it is based.

When running ng eject, you generate a webpack.config.json file. Looking at the file package.json you will see that the commands to launch have slightly changed:

ng serve --> npm start ng build --> npm run build ng e2e   --> npm run e2 

If you want to undo ng eject, you will have to edit your .angular.cli.json file and set ejected to false:

"project": {    ...   "ejected": false } 
like image 157
Mistalis Avatar answered Oct 22 '22 03:10

Mistalis


ng eject basically get-rid of angular cli scripts and introduce webpack scripts in package.json, underlying webpack.config.js file mainly for comprehensive way to manage the project and it will be completely our responsibility to manage the project configurations after this.

A comparison of package.json scripts before and after is below, enter image description here

check https://medium.jonasbandi.net/to-use-angular-cli-or-not-187f87d0b550 for further read.

like image 21
AGan Avatar answered Oct 22 '22 02:10

AGan