在 Angular 8 的资产文件夹中获取徽标的不同版本
Get different builds for logo in assets folder in Angular8
资产文件夹中有2个城市同名的logo.jpeg。当我说 build: london 时,我希望伦敦徽标出现在项目中。我不想那样给"img source in assets / london / logo.jpeg or assets / paris / logo.jpeg"。我的build: city应该是根据city的logo来的
app.component.html
<div class="condition1">
<img src="/assets/logo.jpeg">
</div>
angular.json
"root": "",
"sourceRoot": "src",
"prefix": "app",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "tsconfig.app.json",
"aot": false,
"styles": [
],
"scripts": []
},
"configurations": {
"london": {
"assets": [
{ "glob": "*.jpeg", "input": "src/assets/paris", "output": "assets"}
],
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
], "optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"budgets": [
{
"type": "initial",
"maximumWarning": "2mb",
"maximumError": "5mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "6kb",
"maximumError": "10kb"
}
]},
"paris": {
"assets": [
{ "glob": "*.jpeg", "input": "/src/assets/paris/", "output": "assets"}
],
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"budgets": [
{
"type": "initial",
"maximumWarning": "2mb",
"maximumError": "5mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "6kb",
"maximumError": "10kb"
}
]
}
}
},
您可以使用 this article 描述的相同方法。
例如,您可以为每个城市创建一个 assets 文件夹,然后您可以为每个城市定义一个应用程序,唯一的区别是它们使用的 assets 文件夹。
资产文件夹中有2个城市同名的logo.jpeg。当我说 build: london 时,我希望伦敦徽标出现在项目中。我不想那样给"img source in assets / london / logo.jpeg or assets / paris / logo.jpeg"。我的build: city应该是根据city的logo来的
app.component.html
<div class="condition1">
<img src="/assets/logo.jpeg">
</div>
angular.json
"root": "",
"sourceRoot": "src",
"prefix": "app",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "tsconfig.app.json",
"aot": false,
"styles": [
],
"scripts": []
},
"configurations": {
"london": {
"assets": [
{ "glob": "*.jpeg", "input": "src/assets/paris", "output": "assets"}
],
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
], "optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"budgets": [
{
"type": "initial",
"maximumWarning": "2mb",
"maximumError": "5mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "6kb",
"maximumError": "10kb"
}
]},
"paris": {
"assets": [
{ "glob": "*.jpeg", "input": "/src/assets/paris/", "output": "assets"}
],
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"budgets": [
{
"type": "initial",
"maximumWarning": "2mb",
"maximumError": "5mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "6kb",
"maximumError": "10kb"
}
]
}
}
},
您可以使用 this article 描述的相同方法。 例如,您可以为每个城市创建一个 assets 文件夹,然后您可以为每个城市定义一个应用程序,唯一的区别是它们使用的 assets 文件夹。