Svgr: Want to keep the viewBox without using --icon

Created on 23 May 2020  路  2Comments  路  Source: gregberge/svgr

Hi! Awesome work with this library!

I want to keep the viewBox attribute of the SVG without resizing it to 1em, and without having to pass the property implicitly via --svg-props, is there a way to do it?

Thanks 馃

Most helpful comment

Hi @endikai the viewBox is removed by SVGO. What I do to keep it in the code is to have this in my .svgrrc.js:

module.exports = {
  svgoConfig: {
    plugins: {
      removeViewBox: false,
    },
  }
  /* the rest of the config */
};

You can find more info here: https://react-svgr.com/docs/options/
Under the "SVGO config" title.

All 2 comments

Hey @endikai :wave:,
Thank you for opening an issue. We'll get back to you as soon as we can.
Please, consider supporting us on Open Collective. We give a special attention to issues opened by backers.
If you use SVGR at work, you can also ask your company to sponsor us :heart:.

Hi @endikai the viewBox is removed by SVGO. What I do to keep it in the code is to have this in my .svgrrc.js:

module.exports = {
  svgoConfig: {
    plugins: {
      removeViewBox: false,
    },
  }
  /* the rest of the config */
};

You can find more info here: https://react-svgr.com/docs/options/
Under the "SVGO config" title.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

smashercosmo picture smashercosmo  路  3Comments

troch picture troch  路  5Comments

7ynk3r picture 7ynk3r  路  4Comments

VincentCATILLON picture VincentCATILLON  路  5Comments

lm93547 picture lm93547  路  3Comments