Whats the default path for static files in Angular2?

后端 未结 1 1312
天涯浪人
天涯浪人 2020-12-03 10:02

I\'m currently working on a small Angular2 project. In my case i have to reroute some of the requests (like \"/faq\", \"/aboutus\") back to my old backend server to get some

相关标签:
1条回答
  • 2020-12-03 10:10

    According to the current angular-cli readme (v1.0.1):

    You use the assets array in angular-cli.json to list files or folders you want to copy as-is when building your project:

    "assets": [
      "assets",
      "favicon.ico"
    ]
    

    By default the assets folder is configured for this, so you can place your files into a structure like

    ├── src
    .   ├── assets
    .   .   ├── file1.txt
    .   .   ├── img
        .   │   └── image1.png
            └── css
    

    and serve them from url path /img/image1.png etc.

    If you're not happy with the default option, add a folder name of your choice to angular-cli.json, i.e.

    "assets": [
      "static",
      ...
    ]
    

    Create the ./src/static/ folder for your files and serve analogously to the default.

    0 讨论(0)
提交回复
热议问题