Angular 6: Multiple configurations (twas environments)

前端 未结 2 1994
无人共我
无人共我 2021-02-03 19:21

Trying to get angular-cli to recognise multiple configurations in angular.json

C:\\_dev\\myapp>ng serve --configuration development
Configuration         


        
2条回答
  •  礼貌的吻别
    2021-02-03 19:53

    There is a configurations entry in the build and in the serve section of the angular.json file. The serve part needs to know about your custom configuration as well. Assuming your configuration name is debug, add it to the serve section as follows

    "projects": {
      "myApp": {
         [...]
         "architect": {
           "build": {
             [...]
             "configurations": {
               "production": { [...] },
               "debug": { [...] }
             }
           },
           "serve": {
             [...]
             "configurations": {
               "production": {
                 "browserTarget": "myApp:build:production"
               },
               "debug": {
                 "browserTarget": "myApp:build:debug"
               }
             }
           }
         }
       }
     }
    

    Don't forget to adjust myApp to your projects name equal to the direct child of the project section in your angular.json. Also both debug's should match your configuration in build section.

    Then serve with

    ng serve --configuration=debug
    

提交回复
热议问题