Closed jesse-iluminai closed 3 years ago
maybe relate with:https://github.com/webpack-contrib/css-loader/issues/1337
I had the same issue as this and can confirm making the change from: #1337 (comment) has resolved the issue
for me not and I can not understand, how /\.png$/
can match a data:image/svg+xml....
-string.
the only change was, that all png's get converted to inline data uri's (as expected)
I had the same issue as this and can confirm making the change from: #1337 (comment) has resolved the issue
for me not and I can not understand, how
/\.png$/
can match adata:image/svg+xml....
-string. the only change was, that all png's get converted to inline data uri's (as expected)
I've just removed that comment actually as I've found a small problem - so it's not 100% resolved, with regards to .png$, I also have more file extensions that are managed by this, svg jpg etc
Digging into this issue a little deeper and comparing url-loader with asset modules the problem seems to be with the encoding of the generated data:image, in my case there is a # which if I change to %23 then the asset loads.
Bug in decoding
Fixed https://github.com/webpack/webpack/pull/13807, let's wait release
Thanks for the wicked fast turn around to resolution on this all! Looking forward assisting with confirmation when I have a moment.
In the meantime if anyone needs an easy temporary fix, adding a filter to ignore any inline assets starting with data:image/svg+xml
is working for me:
{
loader: "css-loader",
options: {
url: {
// skip any data URLs of type image/svg+xml
filter: (url) => !(url.startsWith("data:image/svg+xml"))
}
}
}
Fixed in webpack, please update webpack to the latest version https://github.com/webpack/webpack/releases/tag/v5.45.1 and remove workaround
confirmed fixed after updating to 5.45.1 and removing my workaround above, thanks as always @alexander-akait 🙌
Has the issue reappeared with 5.46.0? SVGs stopped working as element background images on my css at least.
No, double check webpack version, or provide example of the problem
A generic solution to this problem for people still running into it (and will address url resolution being filtered for absolute paths) is to use loader-utils
const {isUrlRequest} = require('loader-utils');
{
loader: "css-loader",
options: {
url: {
// skip any data URLs or absolute paths
filter: url => isUrlRequest(url)
}
}
}
This was taken from the default url filter for css-loader@3.x
that didn't have this problem,
https://github.com/webpack-contrib/css-loader/blob/v3.6.0/src/index.js#L62
I faced this issue when updating from v5.66.0 to v5.67.0, dataUrls with inlined SVG's stopped working.
CSS sourcecode:
content: url("data:image/svg+xml,%3Csvg width='32' height='32' vie....");
Resulting code:
content: url("data:image/svg+xml,export%20default%20__webpack_public_path__%20%2B%20....%2Fsvg%253E.2d5d40b2.bin%22%3B");
Webpack replaces the SVG by a JS template and emits an asset where it should not. Issue currently happening on v5.88.0.
@Roberto14 I think you have a problem with your configuration, can you provide a reproducible example and I will show you how to fix it
After updating to 6.0.0 from 5.2.6 the default Bootstrap drop down arrow defined as an inline data:image/svg+xml URL no longer displays on screen.
Confirmed in Firefox 89.0.2 and Chrome 91.0.4472.114
Expected Behavior
We should be able to see the drop down arrow as given in the image below:
URL is modified in such a way that it is not able to render
This is an out of the box/untouched Bootstrap 5.0.2 rule as seen below as an image and the copied rule from bootstrap.css
Actual Behavior
After updating to 6.0.0 the arrow no longer renders as seen in the image below.
When using devtools in Firefox to examine the styles for the dropdown, it appears that some encoding has been applied to the data URL, making it unrenderable.
Code
Note: Bootstrap 5.0.2 is set up as a vendor module outside of package.json and therefore not included below.
How Do We Reproduce?
5.2.6 -> dropdown is visible 6.0.0 -> dropdown is not visible