Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Struggling with SVGO options #41

Closed
tizzle opened this issue Nov 14, 2018 · 2 comments
Closed

Struggling with SVGO options #41

tizzle opened this issue Nov 14, 2018 · 2 comments

Comments

@tizzle
Copy link

tizzle commented Nov 14, 2018

Hi, i'm having trouble getting the svgo options to work.
I tried the following:

module.exports = withPlugins(
  [
    withFonts,
    [withOptimizedImages, {
      svgo: {
        plugins: [
          { removeTitle: true },
          { convertPathData: false },
          { removeUselessStrokeAndFill: true },
          { removeAttrs: { attrs: '(stroke|fill)' } },
        ]
      }
    }]
  ],
  nextConfig
);

I then use the ?icon as described in the docs:

import CartIconSVG from '~/assets/icons/cart.svg?sprite';

The SVG displays fine, the sprite is added to the DOM, but titles are not stripped from the resulting SVGs.

Any help is appreciated!

@tizzle
Copy link
Author

tizzle commented Nov 14, 2018

Ok. Stupid me. I completely overlooked the optimizeImagesInDev option.
This has to be set to true to see the proper results in dev. Might be worth a mention in the svgo section of the docs.

This works for me:

module.exports = withPlugins(
  [
    withFonts,
    [withOptimizedImages, {
      optimizeImagesInDev: true,
      svgo: {
        plugins: [
          { removeTitle: true },
          { convertPathData: false },
          { removeUselessStrokeAndFill: true },
          { removeAttrs: { attrs: '(stroke|fill)' } },
        ]
      }
    }]
  ],
  nextConfig
);

Thanks for the great work with next-optimized-images!

@cyrilwanner
Copy link
Owner

Hi @tizzle
I'm sorry that this was not clear in the readme, but cool that you could figure it out in the end :)
Thanks for your issue, I will keep that in mind when I update the readme for version 2 of next-optimized-images which will be released in the next few days. I think the whole svgo section can be improved, with examples on how to enable/disable plugins (might not be clear if you didn't use it before)..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants