Add an option "auto add class name from svg file name".
liamwang opened this issue · 3 comments
liamwang commented
Automatically add class name to <svg>
tag from its svg file name.
What does the proposed API look like?
A file named logo.svg :
<svg class="foo" viewBox="0 0 25 25">
<path d="..."/>
</svg>
The options :
{
test: /\.svg$/,
loader: 'svg-inline-loader',
options: {
className: 'icon-[filename]',
// or
// classPrefix: 'icon-',
// autoClassName: true
}
}
The expected output result :
<svg class="icon-logo" viewBox="0 0 25 25"><path d="..."/></svg>
Martinspire commented
Would be handy indeed. Now I have to manually add classnames to make sure I have certain styling adapted (like coloring fills).
elliottregan commented
Would an option to add a custom class (from string or file name) be accepted? I can look into doing this, but there are a bunch of PRs hanging around as it is...
mabq commented
Has anybody found an alternative way of doing this?