问题描述
更新:2018年12月(请参阅"Aniket"答案)
UPDATE: December 2018 (see 'Aniket' answer)
使用Angular CLI 6时,您需要使用构建器,因为不建议使用ngject,并且很快将在8.0版中将其删除
With Angular CLI 6 you need to use builders as ng eject is deprecated and will soon be removed in 8.0
更新:2018年6月:Angular 6不支持ng弹出**
UPDATE: June 2018: Angular 6 does not support ng eject**
更新:2017年2月:使用ng弹出
UPDATE: February 2017: use ng eject
更新:2016年11月:angular-cli现在仅使用webpack.您只需要使用npm install -g angular-cli正常安装即可. 我们将beta.10和beta.14之间的构建系统从SystemJS更改为Webpack."但实际上,我仅使用angular-cli来生成结构和文件夹,然后,我手动使用了webpack config
UPDATE: November 2016: angular-cli now only use webpack. You only need install normally with npm install -g angular-cli. "We changed the build system between beta.10 and beta.14, from SystemJS to Webpack.", but actually i use angular-cli just to firs structure and folders and then anymore, i use webpack config manually
我已经用以下方法安装了角度cli:
I've installed angular cli with this:
npm install -g angular-cli@webpack
当我使用angular1和web pack时,我曾经修改过"webpack.config.js"文件以执行所有任务和插件,但是在使用angular-cli创建的这个项目上我看不到谁可以工作.这是魔法?
When I worked with angular1 and web pack , i used to modify "webpack.config.js" file to execute all the task and plugins, but i don't see on this project created with angular-cli who does it work. it's magic?
我看到Webpack在工作时正在工作:
I see Webpack is working when i do:
ng serve
"Version: webpack 2.1.0-beta.18"
但是我不明白angular-cli配置的工作方式...
but i don't understand the way that angular-cli config works...
推荐答案
使用Angular CLI 6时,您需要使用构建器,因为不建议使用ngject,并且很快将在8.0中将其删除.这就是我尝试进行 ng弹出
With Angular CLI 6 you need to use builders as ng eject is deprecated and will soon be removed in 8.0. That's what it says when I try to do an ng eject
您可以使用angular-builders软件包( https://github.com/meltedspark/angular-builders )提供您的自定义Webpack配置.
You can use angular-builders package (https://github.com/meltedspark/angular-builders) to provide your custom webpack config.
我已尝试在博客的单个博客文章中总结所有内容-如何使用Angular CLI 6中的自定义webpack配置自定义构建配置
I have tried to summarize all in a single blog post on my blog - How to customize build configuration with custom webpack config in Angular CLI 6
但实际上您添加了以下依赖项-
but essentially you add following dependencies -
"devDependencies": {
"@angular-builders/custom-webpack": "^7.0.0",
"@angular-builders/dev-server": "^7.0.0",
"@angular-devkit/build-angular": "~0.11.0",
在 angular.json 中进行以下更改-
"architect": {
"build": {
"builder": "@angular-builders/custom-webpack:browser",
"options": {
"customWebpackConfig": {"path": "./custom-webpack.config.js"},
注意构建器和新选项customWebpackConfig中的更改.还要更改
Notice change in builder and new option customWebpackConfig. Also change
"serve": {
"builder": "@angular-builders/dev-server:generic",
再次针对服务目标通知生成器中的更改.发布这些更改后,您可以在同一根目录中创建一个名为 custom-webpack.config.js 的文件,并在其中添加您的webpack配置.
Notice the change in builder again for serve target. Post these changes you can create a file called custom-webpack.config.js in your same root directory and add your webpack config there.
但是,与此处提供的 ng弹出配置不同,该配置将与默认配置合并,因此只需添加要编辑/添加的内容即可.
However, unlike ng eject configuration provided here will be merged with default config so just add stuff you want to edit/add.
这篇关于angular-cli哪里是webpack.config.js文件-新的angular6不支持ng弹出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!