bholloway / resolve-url-loader

Webpack loader that resolves relative paths in url() statements based on the original source file
563 stars 71 forks source link

[V4] webpack5 sets devtool to false, and an error is reported #214

Open imcamo opened 2 years ago

imcamo commented 2 years ago

ERROR in ./resources/assets/pages/auth/lottery/lottery.css Module build failed (from ./node_modules/mini-css-extract-plugin/dist/loader.js): ModuleBuildError: Module build failed (from ./node_modules/resolve-url-loader/index.js): Error: resolve-url-loader: error processing CSS a valid source-map is not present (ensure preceding loaders output a source-map) at file://E:\code\m-soa\resources\assets\pages\auth\lottery\lottery.css:1:57 at encodeError (E:\code\m-soa\node_modules\resolve-url-loader\index.js:274:12) at onFailure (E:\code\m-soa\node_modules\resolve-url-loader\index.js:215:14) at processResult (E:\code\m-soa\node_modules\webpack\lib\NormalModule.js:703:19) at E:\code\m-soa\node_modules\webpack\lib\NormalModule.js:809:5 at E:\code\m-soa\node_modules\loader-runner\lib\LoaderRunner.js:399:11 at E:\code\m-soa\node_modules\loader-runner\lib\LoaderRunner.js:251:18 at context.callback (E:\code\m-soa\node_modules\loader-runner\lib\LoaderRunner.js:124:13) at onFailure (E:\code\m-soa\node_modules\resolve-url-loader\index.js:215:5)

bholloway commented 2 years ago

Firstly check you have {sourceMap: true} from sass-loader as shown here. I know this may be obvious but it's often overlooked.

Assuming that is not the problem, please provide a minimum breaking example as an OSS repo.

Tobbe commented 11 months ago

Came here to say I was seeing the same thing. Setting devtool to 'source-map' made resolve-url-loader work, and setting devtool to false gave that error message about source maps.

But @bholloway was correct. It's the sourceMap option that's important. We have a pretty complex setup with postcss-loader, sass-loader and css-loader used in different combination for different scenarios. I had just forgotten to set sourceMap: true on one of the postcss-loader configs 🙂