JetBrains / svg-sprite-loader

Webpack loader for creating SVG sprites.
MIT License
2.02k stars 272 forks source link

option extract: true. Why is -usage added? #398

Open Dima-Dim opened 4 years ago

Dima-Dim commented 4 years ago

In source svg code:

<svg viewBox={`${icon.viewBox}`} width="15" height="15">
    <use xlinkHref={`sprite.svg#${icon.id}`}/>
</svg>

When using the extract: true option, compiling yields:

xlink:href="sprite.svg#iconname-usage"

Why is -usage added? As a result, the link becomes invalid.

kisenka commented 4 years ago

Because iconname is an id of sprite symbol and it's usage can be the same:

<svg>
  <symbol id="iconname">...</symbol>
  ...
  <use xlink:href="#iconname" id="iconname-usage" />
</svg>