0

Im using scss in an angular project. When i use background image like this:

url("/assets/images/test.jpg") My project builds with no problem and i can see the images on my local or even using ng serve --build, but when i upload this to my IIS server, all the background images show a 404 error, because the project is looking for the image in domain/assets/image/test.jpg and not in domain/application/assets/image/test.jpg.

If i change the image url to assets/images/test.jpgusing chrome Devtools, it works perfectly.

But when i try to change the code to assets without the "/" at the start i get the following error in the postcss loader:

Can't resolve 'assets/images/test.jpg' in 'D:\application\src\assets'

Tried with "../" "./" "src/assets" and many others, but the application only compiles when a "/" is written at the start.

Im using basehref to build and rewrite rule on my server but still have the same error.

Who
  • 3
  • 1

1 Answers1

0

Try building with --deploy-url flag

ng build --prod --deploy-url=/application
David
  • 33,444
  • 11
  • 80
  • 118
  • Found out that is a usual problem with postcss loader and relative paths. My building command is this one: `ng build --prod --base--href /DemoCorebitFront/ --deploy-url=/DemoCorebitFront/` – Who Apr 27 '20 at 21:58