gpt4 book ai didi

angular - 如何添加/设置环境 Angular 6 angular.json 文件

转载 作者:太空狗 更新时间:2023-10-29 16:48:16 25 4
gpt4 key购买 nike

如何指定要在 Angular 6+ 中使用的环境? .angular-cli.json 文件似乎已从以前的版本更改为 angular.json 并且其中包含 json 的结构。

我如何/在此文件中的何处指定要使用的环境?

最佳答案

打开 angular.json 文件。我们可以看到默认情况下的配置,它将显示在生产环境中,为您各自的环境添加代码片段。在开发环境中添加 environment.dev.ts 文件,为 qa 添加 environment.qa.ts。根据您的喜好命名。使用

 ng serve --configuration=environment_name

environment_name - (dev,qa,prod) ng 构建可以遵循相同的过程

"configurations": {
"production": {
"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
},
"dev": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.dev.ts"
}
],
"optimization": true,
"outputHashing": "all",
"sourceMap": true,
"extractCss": true,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true
},
"qa": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.qa.ts"
}
],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true
}
}

关于angular - 如何添加/设置环境 Angular 6 angular.json 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50313296/

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