boopathi / react-svg-loader

A loader for webpack, rollup, babel that loads svg as a React Component
MIT License
638 stars 86 forks source link

Can't turn off removeViewBox #295

Open oatmeaI opened 4 years ago

oatmeaI commented 4 years ago

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,
            },
        ],
    },
},
peterkrieg commented 4 years ago

@kvillaniholland curious did you ever find a fix? 🙏

oatmeaI commented 4 years ago

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.

peterkrieg commented 4 years ago

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

oatmeaI commented 4 years ago

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

options: {
    svgo: {
        plugins: [
            { convertPathData: { noSpaceAfterFlags: false } },
            { removeViewBox: false },
        ],
    },
},
SilviaRebelo-Which commented 3 years ago

@kvillaniholland solution worked for me 🙌🏻