简体   繁体   English

ng弹出的目的是什么?

[英]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 ng eject弹出您的应用程序并输出正确的webpack配置和脚本

What is the purpose of this command? 这个命令的目的是什么?

angular-cli is something magic, everything is done in a simple and automatic way. angular-cli是神奇的东西,一切都以简单自动的方式完成。

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. 但有时候,您可能想要根据包的完成方式,添加插件,或者您只是好奇地看到它所基于的Webpack配置。

When running ng eject , you generate a webpack.config.json file. 运行ng eject ,会生成webpack.config.json文件。 Looking at the file package.json you will see that the commands to launch have slightly changed: 查看文件package.json您将看到要启动的命令略有变化:

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: 如果要撤消 ng eject ,则必须编辑.angular.cli.json文件并将ejected设置为false:

"project": { 
  ...
  "ejected": false
}

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. ng弹出基本上去除了角度cli脚本并在package.json中引入webpack脚本,底层webpack.config.js文件主要是为了全面管理项目,在此之后管理项目配置将完全是我们的责任。

A comparison of package.json scripts before and after is below, 之前和之后的package.json脚本的比较如下, 在此输入图像描述

check https://medium.jonasbandi.net/to-use-angular-cli-or-not-187f87d0b550 for further read. 检查https://medium.jonasbandi.net/to-use-angular-cli-or-not-187f87d0b550进一步阅读。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM