最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - svgo removeAttrs how to specify attrs to remove - Stack Overflow

programmeradmin1浏览0评论

I have removeAttrs set to true, I would like to remove all fill, and color:

{
    loader: 'svgo-loader',
    options: {
      plugins: [
        { removeNonInheritableGroupAttrs: true },
        { collapseGroups: true },
        { removeAttrs: true },
      ],
    },
  },

But I don´t know how to specify attrs to remove in there...

I have removeAttrs set to true, I would like to remove all fill, and color:

{
    loader: 'svgo-loader',
    options: {
      plugins: [
        { removeNonInheritableGroupAttrs: true },
        { collapseGroups: true },
        { removeAttrs: true },
      ],
    },
  },

But I don´t know how to specify attrs to remove in there...

Share Improve this question edited Apr 21, 2017 at 19:41 Robert Longson 125k27 gold badges267 silver badges253 bronze badges asked Apr 21, 2017 at 9:33 palyxkpalyxk 3512 gold badges5 silver badges17 bronze badges 5
  • removeUselessStrokeAndFill ?? – Sahil Dhir Commented Apr 21, 2017 at 9:35
  • No remove useless stroke and fill i have tried.. – palyxk Commented Apr 21, 2017 at 9:37
  • Please provide full code – Sahil Dhir Commented Apr 21, 2017 at 9:41
  • thats cool :) :) – Sahil Dhir Commented Apr 21, 2017 at 9:51
  • 1 Could somebody enlighten me as on how to use this on the mand line? I want to get rid of a lot of 'forbidden' data-name attributes in a bunch of SVG files. “svgo . enable=removeAttrs data-name” doesn't work. – Ideogram Commented Aug 24, 2017 at 7:21
Add a ment  | 

1 Answer 1

Reset to default 5

I solved it like this:

{
  loader: 'svgo-loader',
  options: {
    plugins: [
      { removeNonInheritableGroupAttrs: true },
      { collapseGroups: true },
      { removeAttrs: { attrs: '(fill|stroke)' } },
    ]
  }
}
发布评论

评论列表(0)

  1. 暂无评论