I want to use a background image for my website built using React.
I include in the .scss file :
html {
background-color: #FFFCB2;
background-image: url(https://mdn.mozillademos.org/files/11991/startransparent.gif);
}
and I just import the .scss file in my index.jsx main page :
import "styles/index.scss"
And it works perfectly
But when I use the same image saved on my folder, like this :
html {
background-color: #FFFCB2;
background-image: url(../static/images/startransparent.gif);
}
I obtain the following error message in my web client :
./styles/index.scss
Module build failed (from ./node_modules/mini-css-extract-plugin/dist/loader.js):
ModuleParseError: Module parse failed: Unexpected character '' (1:6)
You may need an appropriate loader to handle this file type.
(Source code omitted for this binary file)
Most of the references to this error message (like in this post) refer to including a series of instructions in my webpack.config.
However I have no webpack.config in my main architecture, I am using babel (I'm not sure how these two facts are connected, I am not proficient in JS). So I wouldn't know where to apply this.
How to make images load properly from local? What if I don't have a webpack.config file in my project?
**Edit : It seems my lack of webpack.config comes from the fact that I'm using next. **
My current next.config.js file :
const withTranspileModules = require("next-transpile-modules")
const withTypescript = require("@zeit/next-typescript")
const withSass = require("@zeit/next-sass")
const _ = require("lodash")
const config = {
exportPathMap() {
return {
"/": { page: "/" },
}
},
distDir: "build",
transpileModules: ["@iconify/react"],
}
module.exports = _.flow([,withTranspileModules, withTypescript, withSass])(config)