13

I would like to add my own custom CSS to my new Angular CLI app...

However I am struggling to get this to work and there is not much documentation on how this works which makes it a bit of guess work!

In the image below I have added my custom style sheet in the .angular-cli.json file as so:

  "styles": [
    "styles.css",
    "app/assets/css/styles.css"
  ],

This however does not work...

Kindly advise!

enter image description here

2
  • do you use ng serve ? Commented Mar 1, 2017 at 9:50
  • you can add the path to your index.html Commented Mar 1, 2017 at 11:21

2 Answers 2

13

As per your folder structure, correct path is assets/css/styles.css so change it in your angular-cli.json file as below and check it.

"styles": [
  "styles.css",
  "assets/css/styles.css"
],
Sign up to request clarification or add additional context in comments.

5 Comments

Thanks, that is the path to use. I also had to stop and re-start the app for it to recognise the new location... I was just adding it and refreshing the site.
Yes! Restarting ng serve is what was missing for me.
where is this in angular.json in angular 6?
It is now angular.json not angular-cli.json
How do you use those style in the components? I added "my-styles.scss" in angular.json
3

Simplest way is to create a folder (in src/) call it styles/ place your style.css (or SCSS and all other _variables.scss files) in it then amend angular-cli.json thus:

"styles": [
  "styles/styles.css"
]

1 Comment

There is nothing technically wrong with this answer... it just wasn't explained very well. Nowhere did the OP say that the folder structure had to be under assets.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.