ERROR Failed to compile with 1 errors
This relative module was not found:
* ./images/backgrounds/footer-bg-1.jpg in ./node_modules/cache-loader/dist/cjs.js!./node_modules/css-loader?{"sourceMap":true}!./node_modules/postcss-loader/lib? ...
What file are you putting this line in? Webpack needs to find the file during the build process iirc, so the path needs to be relative to the css file you’re using it in, not a path to where the image will be after the build process.
I created a simple replication of this problem by doing the following:
Cloned the sage repo and checked out tag 9.0.9 (the most recent Sage 9 version)
Used NVM to set Node version to 8.17.0
Ran npm install
Ran npm build to make sure an unmodified repo built correctly (it did).
Added your css to styles/layouts/_footer.scss.
Made the following modifications to comply w/ Stylelint:
Reduced indent to 2 spaces
Changes single quotes around path to double quotes
Ran npm build
Following these steps, I was unable replicate your results. I was able to build with no errors, and the image was copied to the dist folder on build, as expected.
Since you’ve provided no other information about your environment, my initial guesses would be:
You have modified the build process in some way, which is causing the issue.
You are using a version of Node that has some incompatibility w/ some aspect of the build process (unfortunately I don’t have any good suggestions for tracking this down if so).
You have a typo in your path (if I introduce a typo into my path, I get an error very similar to the one you see).
@alwaysblank There’s something real wrong here. I reinstalled Sage 9.0.10, fresh and clean via composer 1.7.2. Then yarn, yarn build and yarn start (I use node 10.22.1, just because reinstalling Sage it installed 9.0.10 that requires node 10. Anyway at the time I was writing first post I used Sage 9.0.9 with node 8.17 and I had same exact error).
Put an image in resources/assets/images/bg.jpg.
Add in resources/assets/styles/main.scss the line body { background-image: url(../images/bg.jpg); } (image is under dist/images) and I get error
Module build failed: Error: resolve-url-loader: CSS error
predicate must return an absolute path or the result of calling next()
I just ran into the issue, create new project from the ground, copied old code from a project of some months ago (working flawlessly in old code) and it just don’t work, debug info doesn’t throw anything interesting…
Downgrading to ~2.3.1 with the same version of sage also does the trick.