Reputation: 2199
I set image to background-image for div in home page in my site in scss file:
background-image: url('../../../assets/images/map.png');
this work correctly when using ng serve
.
But when I build with npm run build:ssr
and run node server.js
, the image is loaded twice - first loading fails, and second succeeds:
in server.js
changed to background-image: url('map.png');
How to avoid loading that image twice?
Upvotes: 0
Views: 980
Reputation: 95
In CSS you dont have to write background-image
instead you can write CSS as follows
.mycssclass{
background: url('/assets/myimage.png');
background-size: contain;
}
P.S. - it works for me and it dont loads the image twice
Upvotes: 3