I am trying to add a background image to a control in a ReactJS project, using css and it's url functionality.
.jumbotron {
background-image: url(../images/image.jpeg);
background-position: center;
background-repeat: no-repeat;
background-size: 100% auto;
color: 6b6b6b;
}
However, a loader is breaking, as it's trying to parse the binary file. An unexpected char. Removing the background line, and all works.
I am using webpack, and my modules are loaded like this:
module: {
loaders: [
{
test: /.jsx?$/,
loader: 'babel-loader',
exclude: /node_modules/,
query: {
presets: ['es2015', 'react']
}
},
{
rules: [
{
test: /\.css$/,
use: [ 'style-loader', 'css-loader' ]
}
]
}
]
}
How can I get my react app to work with this css image as a background url? Creating the project with create-react-app - it works, but I can't see how it's handling the images.
I have a repo: https://github.com/CraigInBrisbane/ReactLearning
Any assistance would be great.
url("../images/image.jpeg")? Note the quotation marks.url-loader?