Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot override options>rule>use to render SVG properly #27

Open
piotrmarkiewicz opened this issue Sep 11, 2019 · 0 comments
Open

Cannot override options>rule>use to render SVG properly #27

piotrmarkiewicz opened this issue Sep 11, 2019 · 0 comments

Comments

@piotrmarkiewicz
Copy link

If two svgs have same classes, classes overrides each other:

<!-- should be red - but it's green -->
<svg viewBox="0 0 4 4" style="height: 100px;">
  <style>.circle_class{fill:red;}</style>
  <circle class='circle_class' cx="2" cy="2" r="2"/>
</svg>
<!-- should be green - and it is -->
<svg viewBox="0 0 4 4" style="height: 100px;">
  <style>.circle_class{fill:green;}</style>
  <circle class='circle_class' cx="2" cy="2" r="2"/>
</svg>

To prevent this sitution, svg-react-loader colud add file name as class prefix using 'classIdPrefix' via gatsby-plugin-react-svg this way:

actions.setWebpackConfig({
  module: {
    rules: [
      {
        test: /\.svg$/,
        include,
        exclude,
        ...otherProps,
        use: {
            loader: 'svg-react-loader',
            options: {
                filters,
                classIdPrefix: true
            }
        },
      }
    ],
  }
})

It's impossible now. I see that anything can be passed through via '...otherProps', but 'use' will be overridden anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants