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

Can't turn off removeViewBox

Open oatmeaI opened this issue 5 years ago • 5 comments

This config still removes the viewBox attribute from SVGs loaded with react-svg-loader. Why is that?

options: {
	svgo: {
		plugins: [
			{
				convertPathData: { noSpaceAfterFlags: false },
				removeViewBox: false,
			},
		],
	},
},

oatmeaI avatar Mar 12 '20 20:03 oatmeaI

@kvillaniholland curious did you ever find a fix? 🙏

peterkrieg avatar Apr 01 '20 14:04 peterkrieg

No - what I ended up doing was changing the viewBox on the particular SVG that was breaking from 0 0 24 24 to 1 0 24 24 - the change was almost imperceptible, but the 1 stopped removeViewBox from removing the property.

oatmeaI avatar Apr 03 '20 17:04 oatmeaI

Ah I see, thanks - I actually ended up just using svgr/webpack instead

peterkrieg avatar Apr 03 '20 18:04 peterkrieg

if anyone else comes across this, it was my fault; the config should have been:

options: {
	svgo: {
		plugins: [
			{ convertPathData: { noSpaceAfterFlags: false } },
			{ removeViewBox: false },
		],
	},
},

oatmeaI avatar Apr 13 '20 17:04 oatmeaI

@kvillaniholland solution worked for me 🙌🏻

SilviaRebelo-Which avatar Sep 03 '21 08:09 SilviaRebelo-Which