svg-inline-loader icon indicating copy to clipboard operation
svg-inline-loader copied to clipboard

Add an option "auto add class name from svg file name".

Open liamwang opened this issue 7 years ago • 3 comments

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>

liamwang avatar Jul 28 '17 16:07 liamwang

Would be handy indeed. Now I have to manually add classnames to make sure I have certain styling adapted (like coloring fills).

Martinspire avatar Aug 30 '17 07:08 Martinspire

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...

elliottregan avatar Jun 04 '18 20:06 elliottregan

Has anybody found an alternative way of doing this?

mabq avatar Aug 01 '20 05:08 mabq