尝试使用angular-cli识别nights=hotel_cost(int(raw_input('How many nights will you be staying? ')))
city=plane_cost(raw_input('\n1. O.R. Tambo International\n2. Capetown
International\n3. King Shaka International\nWhere you flying to? '))
days=car_rental(int(raw_input('How many days will you need a car for?: ')))
total = holiday_cost(nights, city, days)
angular.json
该片段为:
C:\_dev\myapp>ng serve --configuration development
Configuration 'development' could not be found in project 'myapp'.
Error: Configuration 'development' could not be found in project 'myapp'.
"configurations": {
"production": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.production.ts"
}
],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true
},
"development": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.development.ts"
}
],
"optimization": false,
"outputHashing": "all",
"sourceMap": true,
"extractCss": true,
"namedChunks": true,
"aot": false,
"extractLicenses": false,
"vendorChunk": true,
"buildOptimizer": false
}
}
确实存在
src/environments/environment.development.ts
工作正常
答案 0 :(得分:43)
angular.json 文件的configurations
和build
部分中有一个serve
条目。服务部分也需要了解您的自定义配置。假设您的配置名称为 debug ,请将其添加到服务部分,如下所示
"projects": {
"myApp": {
[...]
"architect": {
"build": {
[...]
"configurations": {
"production": { [...] },
"debug": { [...] }
}
},
"serve": {
[...]
"configurations": {
"production": {
"browserTarget": "myApp:build:production"
},
"debug": {
"browserTarget": "myApp:build:debug"
}
}
}
}
}
}
请勿忘记将myApp
调整为与 angular.json 中project
部分的直接子项相等的项目名称。此外,debug
两个文件都应与build
部分中的配置相匹配。
然后用
服务ng serve --configuration=debug
答案 1 :(得分:-5)
对于Angular 2-5,请参阅有关使用Multiple Environment in angular
的逐步解决方案的文章对于Angular 6,请使用ng serve --configuration=dev
注意:角度6也请参考同一篇文章。但是无论您在哪里找到
--env
,都应使用--configuration
。角度6效果很好。