Angular 2/4 : How to load css file from Assets

Viewed 36864

In my .angular-cli.json, I define this :

"styles": [
  "node_modules/bootstrap/dist/css/bootstrap.min.css",
  "src/assets/css/main.css",
  "styles.css"
],

And in my assets folder I have (assets/css/*.css) .. But when i run my app, CSS doesn't loaded .. How can I resolve it please ? You can check jpeg file in attachment

enter image description here

4 Answers

Ran also into this issue, but I did it differently. I did not modify the angular.json. I imported the url in styles.css with @import url("./app/custom-styles/custom-bootstrap.css");. This way you don't need to restart for detection change. And you keep styles.css clean for your general styling stuff.

Don't know if it is the best way, but for me it helped a lot to keep it clean.

always use double dots to go back. a single "../" use to go one directory back. Now check where is your assets folder from your destination folder. for me ../../assets/css/spinner.css helped

Go to assets folder then create new 'CSS folder & a styles.css file. Open 'angular.json' file give the path in "styles" section.

Related