[英]How can I replace file with property fileReplacements on Angular workspace configuration?
I have a problem with Angular workspace configuration when I want to replace file, I will provide some information below:当我想替换文件时,我对 Angular 工作区配置有问题,我将在下面提供一些信息:
My app info:我的应用信息:
Structure结构
example
---e2e
---src
------environments
---------not-supported.html
---------index.prod.html
------index.html
------not-supported.html
---angular.json
angular.json angular.json
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist/example",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "tsconfig.app.json",
"aot": true,
"assets": [
"src/favicon.ico",
"src/assets",
"src/not-supported.html"
],
"styles": [
"src/styles.scss"
]
},
"configurations": {
"production": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"budgets": [
{
"type": "initial",
"maximumWarning": "2mb",
"maximumError": "5mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "6kb",
"maximumError": "10kb"
}
],
"index": {
"input": "src/index.prod.html",
"output": "index.html"
}
},
"replaceNotSupported": {
"fileReplacements": [
{
"replace": "src/not-supported.html",
"with": "src/environments/not-supported.html"
}
]
}
}
},
Script build on package.json file在 package.json 文件上构建脚本
{
"build:prod": "ng build --configuration=production,replaceNotSupported",
}
after I build successfully, Then content on not-supported.html
file is not same with content file on environment/not-supported.html
.在我构建成功后,然后
not-supported.html
文件上的内容与environment/not-supported.html
上的内容文件不同。
How can I do that?我怎样才能做到这一点?
Dose anyone same problem with me?有人跟我有同样的问题吗?
Thanks!谢谢!
I don't know if you still care about this problem.:) try to use "assets":我不知道你是否还关心这个问题。:) 尝试使用“资产”:
"assets": [
"src/favicon.ico",
{
"input": "src/deployment/staging",
"output": "/",
"glob": "*.ico"
}
]
setup assets to every configrations.为每个配置设置资产。 see enter link description here
请参阅在此处输入链接描述
"production": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
},
{
"replace": "src/not-supported.html",
"with": "src/environments/not-supported.html"
}
],
ng build --configuration=production
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.