有没有办法使用命令 ng test
运行 angular cli 测试?告诉下划线编译器使用 ng build --prod
设置?
我问是因为这里经常遇到用ng build --prod
的aot编译错误那个正常编译时不会发生 与 ng build
最佳答案
这是不可能的,我认为这是因为测试架构师的目标是它自己的构建配置。支持 Assets 、脚本和样式等选项,但不支持通常与生产相关的选项,如 AOT。这是因为编译团队considers the feature to be experimental .有一个feature request支持AOT。
要创建生产配置,请将其添加到测试目标。
"test": {
"builder: "@angular-devkit/build-angular:karma",
"options": {
...
},
"configurations": {
"production": {
...
}
}
}
关于angular-cli - 如何在启用生产build设置和 AOT 的情况下运行 angular cli ng 测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45642545/