弹出Webpack配置后如何使用ngcli? [英] How to work with ngcli after ejecting the webpack config?

查看:119
本文介绍了弹出Webpack配置后如何使用ngcli?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要自定义Angular cli项目中的webpack包构建.为了进行配置,我弹出了webpack配置文件.

I need to customise the webpack pack build in an Angular cli project. In order to configure I eject the webpack config file.

ng eject

一旦执行此操作,当出现以下错误时,我将无法再运行webpack build和服务命令.

Once I do that I can no longer run webpack build and serve command as I get the following error.

An ejected project cannot use the build command anymore

如果弹出后无法使用构建命令,那么弹出后使用webpack的最佳方法是什么.

If the build commands can not be used after eject then what is the best way to work with webpack after eject.

推荐答案

运行ng eject命令时,这是在提示下显示的输出:

When you run the ng eject command this is the output that is displayed at the prompt:

ng eject
==========================================================================================
Ejection was successful.

To run your builds, you now need to do the following commands:
   - "npm run build" to build.
   - "npm run test" to run unit tests.
   - "npm start" to serve the app using webpack-dev-server.
   - "npm run e2e" to run protractor.

Running the equivalent CLI commands will result in an error.

==========================================================================================
Some packages were added. Please run "npm install".

所有您需要知道的东西,就在那儿.

Everything you need to know, right there.

package.json内部查看以查看对scripts部分的更新.还有另外两个命令未在上面的输出中显示.

Have a look inside the package.json to see the updates to the scripts section. There are a couple more commands there that are not shown in the output above.

希望这会有所帮助.

更新:

万一有人不知道,即使退出完成后,仍然可以使用CLI生成代码.

In case anyone was not aware, the CLI can still be used to generate code even after the eject has been done.

ng generate component blah这样的命令仍然可以使用.

Commands like ng generate component blah will still work.

这篇关于弹出Webpack配置后如何使用ngcli?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆