Angular2 - What folder for custom CSS / JS files?

后端 未结 3 1421
别那么骄傲
别那么骄傲 2021-01-27 05:49

I have to include a set of CSS and JS files in my angular2 application.

What is the correct folder in order to have them included when I do the build?

3条回答
  •  说谎
    说谎 (楼主)
    2021-01-27 06:28

    If your using the Angular CLI then you can put them anywhere, but I would suggest in a logical place that makes sense in your src/assets folder.

    From there add entries for the js and css files in your angular.cli.json file.

    there is a scripts array and a styles array under each object/app in the apps node.

    look for something like ...

    apps: [
     {
       ...
       "styles": [ "assets/styles/myCustomStyles.css" ],
       "scripts": [ "assets/js/dragevents.js" ]
     }
    ]
    

    If done correctly the cli will automatically add them to your index when it builds.

提交回复
热议问题