Closed julienchazal closed 5 years ago
Can you help me please @sokra or @evilebottnawi ?
@julienchazal please create minimum reproducible test repo
I have a similar issue, but downgrading resolve-url-loader to 2.* fixes the issue for me.
thx @av3nger , i'm closing this issue since i tried on another Windows computer and it worked. Weird...
Just ran into this myself.
In my own case a css directive like background-image: url('../images/someImage.png')
threw the error described above, however changing to an absolute path resolved it, like background-image: url('/images/someImage.png')
.
The thing is though, I don't really understand why mini-css-extract-plugin
is trying to resolve a path like that, it's not importing a module it's just the url at which a browser is supposed to be able to find the resource. I see that in the options there's a publicPath
option, so my best guess is that this module is converting paths in some way.
I'm not trying to assert that something is wrong with the plugin, or that there's a bug or anything, I'm just trying to understand what this plugin is actually designed to do.
Same here @leviwheatcroft
Running into this as well with a background image url().
Using /path/to/img.png
passes the build, but fails to work in the browser. (404 response)
Using path/to/img.png
makes this build fail, but putting this path manually into the browser css properties makes it load the image.
Can we have an option to just ignore these paths, and NOT try to load modules from them?
Was this ever resolved? Having this error our my Travis CI builds using the same url() css property.
update to "mini-css-extract-plugin": "0.8.0" and "resolve-url-loader": "3.1.0", have fixed the issue for me.
Disable the "url" function handling in "css-loader" resolves this problem for me.
{ loader: 'css-loader', options: { url: false } }
Disable the "url" function handling in "css-loader" resolves this problem for me.
{ loader: 'css-loader', options: { url: false } }
This worked for me as well. Thanks a lot!
Disable the "url" function handling in "css-loader" resolves this problem for me.
{ loader: 'css-loader', options: { url: false } }
it will disable url resolving completely, for all css/scss/... files, including those in node_modules
where it may be required. Is it possible to disable url resolution for some files and not for other? Eg, disable it for particular context?
Yes, we have filter
for url
https://github.com/webpack-contrib/css-loader#object
@alexander-akait Dear sir! You just made my day! Thank you!
For people using Symfony Encore webpack configuration ("@symfony/webpack-encore": "1.6.1"
)it can be configured like this:
Encore
.configureMiniCssExtractPlugin()
.configureCssLoader(options => {
options.url = (url, resourcePath) => {
/**
ignore resolving images paths with /img/ prefix like:
background-image: url('/img/bg.jpg');
*/
if (url.startsWith("/img/")) {
//debug: console.log("Ignoring image url: ", url, " -> ", resourcePath);
return false;
}
return true;
};
})
...
For me it's the opposite environment, my build works on Windows but not on Linux docker container(node image) in Windows host. I have no clue if this happens because I'm trying to build my npm project with mounted sources in the Windows host.
Hello,
Using latest version i get this error only on Windows, it's working perfectly on Mac or Linux :
webpack config :
Any ideas please ?