What is the purpose of ng eject?

后端 未结 2 696
野性不改
野性不改 2021-02-03 23:34

The documentation is very brief with this topic:

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

2条回答
  •  夕颜
    夕颜 (楼主)
    2021-02-04 00:11

    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
    }
    

提交回复
热议问题