Vue-svg-loader: Add an option to disable SVGO completely

Created on 4 Jul 2018  路  4Comments  路  Source: visualfanatic/vue-svg-loader

Hi,

Would it be possible to add an option to remove SVGO's optimisations from the loader completely?
Currently SVGO manages to strip my style tags, even when I set removeStyleElement: false (it strips the style tag from <defs> even after I've set every svgo plugin to false) 馃槙

Most helpful comment

@andreasvirkus disabling SVGO is now included in 0.10.0, just pass svgo: false to loader options.

All 4 comments

Literally having exactly the same problem and came here to see if anybody else had as well.

Gonna take a look through the source and see if I can make a PR.


Edit: Made a PR that includes a useSvgo property that can be set to false. In the meantime, you're welcome to use the dev branch for the PR in your package.json:

{
  "devDependencies": {
    "vue-svg-loader": "sam3d/vue-svg-loader#disable-svgo-option"
  }
}
{
  test: /\.svg$/,
  loader: 'vue-svg-loader',
  options: {
    useSvgo: false, // (optional) default: true
  }
}

@sam3d I created a custom SVG loader to get around what I thought was a vue-svg-loader specific issue and it turns out Vue's vue-template-compiler is the issue. See a relevant comment thread:
https://forum.vuejs.org/t/about-using-style-tags-inside-templates/7275

I've just changed my SVG structure to use attributes where possible and inline the styles where not. 馃槙

@andreasvirkus disabling SVGO is now included in 0.10.0, just pass svgo: false to loader options.

@andreasvirkus disabling SVGO is now included in 0.10.0, just pass svgo: false to loader options.

Thanks!
Just for example, I used this way in 'vue.config.js' and it worked:

麓 chainWebpack: config => { const svgRule = config.module.rule('svg') svgRule.uses.clear() svgRule.use('vue-svg-loader').loader('vue-svg-loader').options({svgo: false}) },

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dsbert picture dsbert  路  6Comments

santigarcor picture santigarcor  路  8Comments

Chucheen picture Chucheen  路  5Comments

jpetko picture jpetko  路  5Comments

valangar picture valangar  路  3Comments