svgr icon indicating copy to clipboard operation
svgr copied to clipboard

Exceptions for removing SVG attributes

Open fl-y opened this issue 1 year ago • 1 comments

🚀 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

fl-y avatar Mar 06 '23 06:03 fl-y

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.

stale[bot] avatar May 21 '23 19:05 stale[bot]