Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Resolving assets path in css with Angular 7 cli

I have an image (toolbar-bg.svg) in my assets folder, and trying to set it as the background image for an element. If I apply background: url('assets/toolbar-bg.svg') then it won't build because postcss can't resolve the file, but if I apply background: url('../assets/toolbar-bg.svg') it builds but then the path is wrong client side and it can't load the image. How do I get this to work properly?


1 Answers

Try These pathes

  1. background: url('~/assets/toolbar-bg.svg')
  2. background: url('/assets/toolbar-bg.svg')

If none of them worked then you better try physical adresses

like image 178
Arian Shahalami Avatar answered Apr 11 '26 06:04

Arian Shahalami



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!