Answer the question
In order to leave comments, you need to log in
Unable to load image in react?
Is this a problem with react or with webpack
src
--imgs
------bg.jpg
--style.css
style.css
body {
background-image: url('./imsg/bg.jpg'); // Текущая папка/imgs/bg.jpb
}
Answer the question
In order to leave comments, you need to log in
It's likely that images need to be required so that Webpack can process them.
An example with HTML, but in terms of styles everything should be similar
Something like this:
- not ok.
- OK.
So Webpack should be able to process and replace the original img.
<img src={"/images/resto.png"} />
<img src={require('/images/image-name.png')} />
Hello, try to write /imsg/bg.jpg
without a dot at the beginning, it's strange, but, in my opinion, it works in css
. Also, I noticed that in the description you wrote that your folder is called "imgs" and in the path you wrote "imsg".
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question