Inline svg imports #4829
Replies: 8 comments 7 replies
-
Does |
Beta Was this translation helpful? Give feedback.
-
Is there a way to do it with transformers in the config file? I am also using storybook which uses webpack, so ideally I don’t need to any anything to the import path |
Beta Was this translation helpful? Give feedback.
-
(I’ll also try your suggestion tomorrow) |
Beta Was this translation helpful? Give feedback.
-
I thought this might work, but no success: {
"extends": "@parcel/config-default",
"transformers": {
"*.{ts,tsx}": [
"@parcel/transformer-typescript-tsc"
],
"*.svg": [
"@parcel/transformer-raw"
]
},
+ "optimizers": {
+ "*.svg": [
+ "@parcel/optimizer-data-url"
+ ]
}
} |
Beta Was this translation helpful? Give feedback.
-
Sadly I could not get your suggestion to work |
Beta Was this translation helpful? Give feedback.
-
I have the exact same problem right now … would love to hear a solution for this. |
Beta Was this translation helpful? Give feedback.
-
index.js: import svg from "./swim.svg";
console.log(svg); parcelrc: {
"extends": "@parcel/config-default",
"transformers": {
"*.svg": ["@parcel/transformer-inline-string", "..."]
}
} Output: (function () {
...
var $c9cd9a05029e9b75462fe50fc01e00$exports = {};
$c9cd9a05029e9b75462fe50fc01e00$exports = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SV...></svg>";
...
})(); |
Beta Was this translation helpful? Give feedback.
-
@mischic So there is no way to statically bring in a Convert:
to
This is much more useful as it avoids the extra fetch and only inline svg can be styled by css. |
Beta Was this translation helpful? Give feedback.
-
Hi there!
I am using parcel@2 and I am looking to inline some SVGs rather than just importing the path
Here is my current config:
So I'm using the
transformer-raw
. Ideally I would use something liketransformer-string-inline
but that would already base64 encode the imageBeta Was this translation helpful? Give feedback.
All reactions