Skip to content

v2.6.0

Compare
Choose a tag to compare
@TrySound TrySound released this 13 Sep 13:59

If you enjoy SVGO and would like to support our work, consider sponsoring us directly via our OpenCollective.

We have some good stuff in this release

Better syntax errors (#1553)

Before people struggled to figure out what and why happens with such cryptic error

Error: Error in parsing SVG: Unquoted attribute value
Line: 1
Column: 29
Char: 6
File: input.svg

This gives too little information when a lot of svgs are transformed.

New errors look like this, include context and point to exact location with the issue.
We hope this will solve many issues when dealing with bundlers and other tools integrations.

Error: SvgoParserError: input.svg:2:29: Unquoted attribute value

  1 | <svg viewBox="0 0 120 120">
> 2 |   <circle fill="#ff0000" cx=60.444444" cy="60" r="50"/>
    |                             ^
  3 | </svg>
  4 |

pefixIds plugin is now idempotent (#1561)

To get better compression results SVGO uses multipass option. This option is used
to run prefixIds plugin only once to prefix ids and classes properly.

Though sometimes users run svgo manually a few times which leads to duplicated
prefixes and make code much bigger. To solves this prefixIds was redesigned
to add prefix only when it does not exit in ids and classes.

Eventually all plugins are planned to be determenistic and idempotent
so multipass option would not be necessary and single pass compression
could be as effective as possible.

New js2svg options (#1546)

js2svg.eol: 'lf' | 'crlf'

Allows to customize end of line characters which is usually resolved by os.EOL in node.

finalNewline: boolean

Ensures SVG output has a final newline which is required for some tools like git.

Fixes and refactorings

Follwing plugins are migrated to the new visitor plugin api and covered with tsdoc

Also fixed a few bugs

  • add xmlns:xlink in reusePaths plugin when missing (#1555)
  • fixed removeNone param in removeUselessStrokeAndFill plugin (#1549)

Thanks to @XhmikosR, @matheus1lva, @deepsweet, @omgovich, @adalinesimonian and @TrySound