gregberge / svgr

Transform SVGs into React components 🦁
https://react-svgr.com
MIT License
10.59k stars 422 forks source link

Exceptions for removing SVG attributes #832

Open fl-y opened 1 year ago

fl-y commented 1 year ago

🚀 Feature Proposal

Make it possible to add an exception array for attribute removal for @svgr/babel-plugin-remove-jsx-attribute

Motivation

I remove the 'fill' and 'fillOpacity' properties so that I can change the colour when I want for most SVGs, however this doesn't work for certain SVGs

Example

module.exports = {
// settings
  jsx: {
          babelConfig: {
              plugins: [
                  [
                      '@svgr/babel-plugin-remove-jsx-attribute',
                      {
                          elements: ['svg', 'path'],
                          attributes: ['fill', 'fill-opacity'],
                          exclude: ['example.svg', 'example-2.svg'],
                      },
                  ],
              ],
          },
      },
}

Pitch

~Will attempt to implement it myself with a subsequent PR~ but thought other devs will probably need this some way or another

Couldn't easily figure out how to access the filename - will try to pick it up some time later

stale[bot] commented 1 year ago

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.