英文:
Get different builds for logo in assets folder in Angular8
问题
在资产文件夹中有两个城市都有同名的 logo.jpeg 图片。当我说 "build: london" 时,我希望伦敦的 logo 出现在项目中。我不想像这样给出路径:"img source in assets / london / logo.jpeg or assets / paris / logo.jpeg"。我的 "build: 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/london", "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"
}
]
}
}
}
}
英文:
There is a logo.jpeg with the same name for 2 cities in asset folder. And when I say build: london, I want the london logo to come on the project. I do not want to give like that "img source in assets / london / logo.jpeg or assets / paris / logo.jpeg". my build: city should come according to the city's 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"
}
]
}
}
},
答案1
得分: 0
你可以使用与此文章描述的相同方法。
例如,您可以为每个城市创建一个资产文件夹,然后可以为每个城市定义一个应用程序,唯一的区别是它们使用的资产文件夹不同。
英文:
You can use the same approach that this article describes.
For example, you can have an assets folder for each city, and then you can define an app for each city where the only difference is the assets folder they use.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论