Reputation: 267059
In my css file I have the line: background-image: url(/img/bg.svg);
In dev mode this resolves to src/img/bg.svg
(the stylesheet is at src/css/components/styles.css
)
But in prod mode, I see a 404 error in console that bg.svg
was not found.
What am I doing wrong?
Upvotes: 0
Views: 218
Reputation: 181735
The simplest way is to use a path relative to the CSS file, rather than absolute, because relative paths are resolved through Webpack while absolute paths are preserved as-is, so they work mostly by luck.
Another way is to put the image in the public
folder, but it puts more responsibility onto you to make sure that the paths is correct, that your web server is configured correctly, and so on.
Upvotes: 1