Vue-svg-loader: Removes viewbox

Created on 18 Nov 2018  路  6Comments  路  Source: visualfanatic/vue-svg-loader

Before vue-svg-loader my svg looks like this.

<svg xmlns="http://www.w3.org/2000/svg" width="59.225" height="15" viewBox="0 0 59.225 15">

When i include it as a vue component it removes viebox. I can not scale my svg without viewbox.

<svg xmlns="http://www.w3.org/2000/svg" width="59.225" height="15">

Most helpful comment

Usage with Vue CLI:

...
.loader('vue-svg-loader')
.options({
  svgo: {
    plugins: [{ removeDimensions: true }, { removeViewBox: false }]
  }
})
...

Complete list of SVGO options.

All 6 comments

Remove the width and height attributes and svgo will stop removing viewBox, or add the option object to your rule config:

config.module.rules.push({
  test: /\.svg$/,
  loader: "vue-svg-loader",
  options: {
    svgo: {
      plugins: [{ removeDimensions: true }, { removeViewBox: false }]
    }
  }
});

@RainArro have you checked @FistMeNaruto solution? Just disable the removeViewBox SVGO plugin and you should be fine.

Thank you :)

Usage with Vue CLI:

...
.loader('vue-svg-loader')
.options({
  svgo: {
    plugins: [{ removeDimensions: true }, { removeViewBox: false }]
  }
})
...

Complete list of SVGO options.

Why the choice to remove the viewBox if it's present ?

@KaliaJS it reduces size by a view bytes, which is the point of SVGO.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dsbert picture dsbert  路  6Comments

Peppe87 picture Peppe87  路  4Comments

ryanrca picture ryanrca  路  5Comments

Mister-Hope picture Mister-Hope  路  3Comments

valangar picture valangar  路  3Comments