Angular2 + webpack do not deploy robots.txt

I made this work with Angular6.

Place your robots.txt in the src folder, the same folder as the favicon.ico.

In your angular.json file

              "assets": [
              "src/favicon.ico",
              "src/assets",
              "src/robots.txt"
            ],

You may need to ng serve again, then point to http://localhost:4200/robots.txt


I have found my solution in this issue: https://github.com/angular/angular-cli/issues/1942

robots.txt is in src/ directory
Modify angular-cli.json

"apps": [
{
  "root": "src",
  "outDir": "dist",
  "assets": ["assets", "robots.txt"],
 ....

Use the assets array to declare files you want to be placed in the root of dist/