用于 ng serve 和 ng build 的 cli 配置中的不同资产 [Angular 5]
问题描述:
当我使用 ng build
时是否可以使用不同的资产数组?
Is possible to use different assets array when i use ng build
?
"assets": [
"assets",
"favicon.ico",
{
"glob": "**/*",
"input": "../externalDir",
"output": "./app/",
"allowOutsideOutDir": true
}
]
就我而言,当我使用 ng build
时,我只想构建这个:
In my case when i use ng build
i want to build only this:
"assets": [
"assets",
"favicon.ico"
]
答
我不认为有针对环境特定资产的选项.但是您可以在 angular-cli.json 中创建其他应用程序,它们基本上只是彼此的副本,但具有不同的资产.例如
I don't believe there is an option to do environment specific assets. But you can make additional apps in your angular-cli.json which are basically just copies of each other, but with different assets. For example
// angular-cli.json
"apps": [
{
"root": "src",
"outDir": "dist",
"name": "devApp",
"assets" : [
"assets",
"favicon.ico",
{
"glob": "**/*",
"input": "../externalDir",
"output": "./app/",
"allowOutsideOutDir": true
},
],
...
},
{
"root": "src",
"outDir": "dist",
"name": "prodApp",
"assets": [
"assets",
"favicon.ico"
],
...
}
]
现在您可以通过构建特定的应用程序"来构建不同的资产
Now you can build your assets differently by building a specific "app"
// dev
ng build --app=0
// or
ng build --app=devApp
// prod
ng build --app=1
// or
ng build --app=prodApp
Angular cli docs 在多个应用上.
Angular cli docs on multiple apps.