egoist / svg-to-vue-component

Transform SVG files into Vue SFC (with hot reloading and SVGO support)
MIT License
235 stars 18 forks source link

can't set preserveAspectRatio and viewbox properties #19

Open stofi opened 5 years ago

stofi commented 5 years ago

I can't seem to set preserveAspectRatio because it get's converted from camel case to the kebab case: preserve-aspect-ratio

When I set it manualy in the svg file itself the property is not present in the actual rendered html code.

andrewwk commented 5 years ago

It works for me when I configure the svgo options. Here's my config:

{
  loader  : 'svg-to-vue-component/loader',
  options : {
    svgoConfig : {
      plugins : [
        { removeViewBox : false },
        { removeDimensions : true },
        {
          addAttributesToSVGElement : {
            attributes : [ `preserveAspectRatio="xMidYMid meet"` ]
          }
        },
        { convertShapeToPath : true },
        { mergePaths : false }
      ]
    }
  }
}