I'm new to set up webpack with React environment. The issue I have now is that background-size and background image do not work for the background image I set in react component. It worked when I set background-image and background-size and position in the same file. in other words, when I set the image in component, and define background-size and position in scss, it does not work. I believe my webpack setting cause this issue.
-webpack-
{
test: /\.css$/,
use: ['style-loader', 'css-loader'],
},
{
test: /\.s[ac]ss/i,
use: ['style-loader', 'css-loader', 'sass-loader'],
},
{
test: /\.(png|svg|jpg|gif)$/,
use: ['file-loader'],
},
-component-
<div className="image"
style={{
background: `url(${imageUrl})`,
}}/>
-scss-
.image {
width: 100%;
height: 95%;
background-size: cover;
background-position: center;
margin-bottom: 5px;
}
With this source, the result I got is that image was displayed, however the image does not cover.