bholloway / resolve-url-loader

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

resolve-url-loader can not coexist with cssnano #130

Closed didiself closed 4 years ago

didiself commented 5 years ago

My site base on Nextjs. When cssnano coexist with resolve-url-loader , resolve-url-loader not work.

scss:

background: url("./loading.png");

webpack:

rule.use.splice(cssLoaderIndex + 1, 0, {
              loader: 'postcss-loader',
              options: {
                plugins: [
                  require('postcss-flexbugs-fixes'),
                  require('autoprefixer'),
                  require('cssnano')({
                    preset: 'default',
                    normalizeUrl:false
                  })
                ]
              }
            })

            const isCss = /\\\.css\$/.test(rule.test + '')
            !isCss &&rule.use.splice(cssLoaderIndex + 1, 0, {
              loader: 'resolve-url-loader',
              options: {
                // engine: 'rework',
                keepQuery:true,
                debug:true,
                sourceMap: true
              }
            })

When cssnano +resolve-url-loader : image

When cssnano remove: resolve-url-loader work!!

So, how can I fix it?

terox commented 5 years ago

I think that it could be related also with #129

bholloway commented 5 years ago

@terox please ensure that resolve-url-loader occurs immediately after sass-loader. I suspect that you have css-nano in between, which would probably break things.

Otherwise please create an open-source repo with a minimum breaking example that I can look at.

bholloway commented 4 years ago

Closing from lack of response. Happy to reopen if any of the existing participants are still having problems.