vladshcherbin / rollup-plugin-svg-sprite

Create external svg sprite file from your bundle using Rollup
21 stars 5 forks source link

How to apply SVGO plugins #9

Open mikeriley131 opened 9 months ago

mikeriley131 commented 9 months ago

I'm trying to get this to take SVGO plugins like this:

// rollup.config.js

const config = {
  ...,
  plugins: [
    svgSprite({
      outputFolder: './build,
      plugins: [
        'preset-default',
        {
          name: 'addAttributesToSVGElement',
          params: {
            attributes: [
              { 'fill-rule': 'currentColor' },
              { 'aria-hidden': 'true' },
              { role: 'presentation' },
            ]
          }
        }
      ]
    })
  ]
}

But I am not seeing the plugins take effect in the generated sprite sheet. Am I doing this incorrectly?

Thanks.

vladshcherbin commented 9 months ago

@mikeriley131 Hey 👋

You're absolutely right in your config, however this package was created when SVGO was at version 1 and now it's version 3. The configuration in new versions was changed and that's why it's not working correctly.

Here's how it was in 1.3.2 - https://github.com/svg/svgo/blob/v1.3.2/examples/test.js

Since I'm not using rollup for the past few years the best thing would probably be this package deprecation.

Sorry

mikeriley131 commented 9 months ago

OK, thanks for letting me know.