如何 运行 使用 ngx-build-plus (extra-webpack-config) 进行端到端测试?

How to run e2e test with ngx-build-plus (extra-webpack-config)?

我使用 ngx-build-plus 来包含一个特殊的 webpack 加载器,以将特殊的自定义文件集成到我们的 Angular-CLI 构建过程中(Angular 10).

一切正常,但是我找不到以这种方式使用 e2e-tests 的方法,它甚至没有采用 --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"
}