Search code examples
angularangular-cliproject-settings

In Angular CLI (1.3+) How can I ensure that my web.config file outputs to my 'dist' directory


In order to copy any file like a favicon.ico or a web.config from my Angular CLI project out to my dist folder upon running my production build command: ng build --env=prod, where do I have to put my file that I want copied and do I need to reference it in my .angular-cli.json file?


Solution

  • A few things you must remember when outputting files to your dist directory.

    Ensure that the file you want exported already exists in your src directory. If you have both a favicon.ico and a web.config file that you want to output to the root of the dist directory they need to be in the root of your src directory.

    Next you need to make a change to .angular-cli.json like so:

    "apps": [
        {
          "root": "src",
          "outDir": "dist",
          "assets": [
            "assets",
            "favicon.ico",
            "web.config"
          ],
          ...
        }
      ],