ben*_*oam 8 angular-cli angular angular-json angular11
我使用angular.jsonfileReplacements文件中的Angular cli 配置来替换文件夹内容,如下所示:
{
"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/"
}
]
}
}
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
请注意,在replace值中我使用的是文件夹路径而不是文件路径。这是 Angular 10 的工作代码。
我升级到 Angular 11,现在尝试使用以下命令构建产品版本时遇到错误:
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.
Run Code Online (Sandbox Code Playgroud)
ESLint 向我展示了这个警告:
String does not match the pattern of "\.(([cm]?j|t)sx?|json)$".
Run Code Online (Sandbox Code Playgroud)
我能用这个做什么?这是 Angular 11 的错误吗?我应该使用不同的方法吗?
任何帮助将不胜感激。
所以事实证明,这个功能实际上是一个Bug, 事实上,在 Angular 10 之前可以进行文件夹替换的事实从一开始就不应该工作。
我在angular-cli repo中问了这个问题,这是我得到的答案:
很抱歉您在更新后遇到此问题。但是,替换目录从来都不是文件替换功能支持的用例。
我想这需要开发商来处理。就我而言,我只是添加了一个脚本来使用shell命令执行此操作,并且我使用npm run script.
| 归档时间: |
|
| 查看次数: |
9299 次 |
| 最近记录: |