I am currently working on a project using Create-React-App and I am trying to set a background image for my header section. Here is how I'm attempting to do it:
background-image: url('~/Screenshot_11.png');
However, I encountered an error when trying to import the image:
./src/styles/main.scss (./node_modules/css-loader/dist/cjs.js??ref--6-oneOf-5-1!./node_modules/postcss-loader/src??postcss!./node_modules/sass-loader/lib/loader.js??ref--6-oneOf-5-3!./src/styles/main.scss) Module not found: You attempted to import ../../../../../../../Screenshot_11.png which falls outside of the project src/ directory. Relative imports outside of src/ are not supported.
I have already specified the homepage in my package.json file as follows:
"homepage": "http://localhost:3000",
This method has worked for me in previous projects, but for some reason I am having difficulty importing the image correctly this time around.