问题描述
我使用 ngx-build-plus 包括一个特殊的webpack加载器,以将特殊的自定义文件集成到我们的Angular-CLI构建过程(Angular 10)中。
一切正常,但是我找不到以这种方式使用e2e测试的方法,甚至没有采用--extra-webpack-config
选项...
$ ng e2e --extra-webpack-config webpack.partial.js
UnkNown option: '--extra-webpack-config'
UnkNown option: 'webpack.partial.js'
如何修复e2e测试以使用webpack.partial.js
?
解决方法
这里可能会晚一点,但是您需要在angular.json
文件中更改构建器
替换:
"builder": "angular-cli-builders:custom-webpack-browser"
使用
"builder": "ngx-build-plus:browser"
文档中未提及,因此我不得不做一些digging in their sample projects。像魅力一样工作
,经过很多尝试,我完全找不到使它与ngx-build-plus
一起工作的方法。但是,我发现还有一个不同的模块@angular-builders/custom-webpack
,它提供了无缝扩展Angular-CLI Webpack配置的确切功能,并且可以与我的e2e测试完美配合。无需将参数传递给构建过程,因为angular.json
配置文件中配置的webpack.conf片段的名称:
"customWebpackConfig": {
"path": "./webpack.config.js"
}