【发布时间】:2021-03-24 13:33:15
【问题描述】:
我在 angular.json 文件中使用 angular cli config fileReplacements 来替换文件夹内容,如下所示:
{
"projects": {
"myProject": {
"architect": {
"build": {
"configurations": {
"prod": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
},
{
"replace": "node_modules/moment/locale/",
"with": "src/moment-js-locale/"
}
]
}
}
}
}
}
}
}
请注意,在replace 值中,我使用的是文件夹路径而不是文件路径。
这是 Angular 10 的工作代码。
我升级到 Angular 11,现在尝试使用以下命令构建 prod 版本时出现错误:
ng build --prod
我得到的错误是:
Schema validation failed with the following errors:
Data path ".fileReplacements[1]" should NOT have additional properties(replace).
Data path ".fileReplacements[1].replace" should match pattern "\.(([cm]?j|t)sx?|json)$".
Data path ".fileReplacements[1]" should match exactly one schema in oneOf.
ESLint 向我显示此警告:
String does not match the pattern of "\.(([cm]?j|t)sx?|json)$".
我能用这个做什么?这是 Angular 11 的错误吗?我应该使用其他方法吗?
任何帮助将不胜感激。
【问题讨论】:
标签: angular angular-cli angular11 angular-json