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

查看:19
本文介绍了弹出 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 和 serve 命令,因为我收到以下错误.

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天全站免登陆