Angular2 + webpack do not deploy robots.txt

后端 未结 3 1576
北海茫月
北海茫月 2020-12-31 02:33

I am creating a web site with Angular2@2.1.2. I am using Webpack with default settings (as a dependency).

Here is my package.json

\"dependencies\": {         


        
3条回答
  •  青春惊慌失措
    2020-12-31 02:39

    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

    This will only work if you are not catching all unknown routes (path:'**') in your router module(s).

提交回复
热议问题