How can I copy a different web.config file for debug vs production in Angular?

Viewed 130

In my Angular app, I have a web.config file that I use for redirecting to https.

I only want this web.config to be present when I do a --prod build, but I can't figure out how to make this happen.

In my angular.json file, I have the following:

"build": {
       "options": {
          ...
          "assets": [
             ... lots of assets here ... <-- These don't get copied on a prod build
             {         
                "glob": "web.config",
                "input": "src/environments/debug",
                "output": ""
             }]
       },
       "configurations": {
          "production": {
                      ...
                "fileReplacements": [
                {
                      "replace": "src/environments/environment.ts",
                      "with": "src/environments/environment.staging.ts"
                }],
                "assets": [
                {
                   "glob": "web.config",
                   "input": "src/environments/production",
                   "output": ""
                }],
                ...
          }      
       }
    }

By including the assets in the production configuration, it will ONLY copy the web.config and ignores all the assets in the options.

I would expect that it would execute the production along with the options.

I also tried using the fileReplacements to replace the web.config, but no dice there either.

How can I configure my build so that I get a debug version (or no version) of the web.config vs a different version for a --prod build?

0 Answers
Related