when i use react-svg-loader, it seems make <use> label disappear
Mamba-working opened this issue · 4 comments
Mamba-working commented
original:
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="56" height="48">
<defs>
<path id="b" d="M2 1.982h40v31.706H2V1.982z"/>
<filter id="a" width="135%" height="144.2%" x="-17.5%" y="-15.8%" filterUnits="objectBoundingBox">
<feOffset dy="2" in="SourceAlpha" result="shadowOffsetOuter1"/>
<feGaussianBlur in="shadowOffsetOuter1" result="shadowBlurOuter1" stdDeviation="2"/>
<feColorMatrix in="shadowBlurOuter1" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.3 0"/>
</filter>
</defs>
<g fill="none" fill-rule="evenodd">
<g transform="translate(6 6)">
<use fill="#000" filter="url(#a)" xlink:href="#b"/>
<use fill="#E3ECF9" xlink:href="#b"/>
</g>
<path fill="#ACC8EE" d="M20.481 19.376L8 31.354v8.83h40v-5.985l-7.774-8.09-6.434 6.14z"/>
</g>
</svg>
but after render, it becomes this:
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="56" height="48">
<defs>
<path id="170971.10000000248-50234488574" d="M2 1.98h40v31.7H2V1.99z">
</path>
<filter id="170971.10000000248-23528313101" width="135%" height="144.2%" x="-17.5%" y="-15.8%" filterUnits="objectBoundingBox">
<feOffset dy="2" in="SourceAlpha" result="shadowOffsetOuter1">
</feOffset>
<feGaussianBlur in="shadowOffsetOuter1" result="shadowBlurOuter1" stdDeviation="2">
</feGaussianBlur>
<feColorMatrix in="shadowBlurOuter1" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.3 0">
</feColorMatrix>
</filter>
</defs>
<g fill="none" fill-rule="evenodd">
<g transform="translate(6 6)">
<use fill="#000" filter="url(#170971.10000000248-23528313101)" xlink:href="#b">
</use>
<use fill="#E3ECF9" xlink:href="#b">
</use>
</g>
<path fill="#ACC8EE" d="M20.48 19.38L8 31.35v8.83h40V34.2l-7.77-8.1-6.44 6.15z">
</path>
</g>
</svg>
Mamba-working commented
when use chrome t open the svg file, label has children to show,but there is none in react
Mamba-working commented
oh, it seems that id in <defs>
is not Corresponding with <use xlink:href="#b"/>
or <use filter="url(#a)">
goququ commented
Hi, you can change SVGO config like this
use: [
'babel-loader',
{
loader: 'react-svg-loader',
options: {
svgo: {
plugins: [
{cleanupIDs: false}
]
}
}
}
]
list of all available plugins here
stale commented
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.