gpt4 book ai didi

angular - 无法设置 fileReplacements 以使用 Angular 11 替换文件夹内容

转载 作者:行者123 更新时间:2023-12-04 12:57:02 25 4
gpt4 key购买 nike

我正在使用 angular cli 配置 fileReplacements在 angular.json 文件中替换文件夹内容,如下所示:

{
"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 value 我使用的是文件夹的路径而不是文件的路径。
这是 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 的错误吗?我应该使用不同的方法吗?
任何帮助将不胜感激。

最佳答案

所以事实证明这个功能实际上是一个 Bug 🙂
从一开始就不应该在 Angular 10 之前进行文件夹替换这一事实。
我在 angular-cli repo 中问过这个问题这是我得到的答案:

I am sorry that you are experiencing this issue after updating. However, replacing directories was never a supported use-case of the file replacements feature.


我想这需要由开发人员处理。
就我而言,我只是添加了一个脚本来使用 shell命令,我正在使用 npm run script 将此脚本作为预构建脚本运行.

关于angular - 无法设置 fileReplacements 以使用 Angular 11 替换文件夹内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65280076/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com