Angular 2/4 : How to load css file from Assets
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.
Go to assets folder then create new 'CSS folder & a styles.css file. Open 'angular.json' file give the path in "styles" section.
I got same error once I have started Angular 4 project
What I have done is
In my assets there is no css
"assets": [
"assets",
"favicon.png"
],
And in style
"styles": [
"../src/assets/css/main.css",
]
And then please do ng serve again
Hope this helps
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