Skip to content

Releases: svg/svgo

v2.2.1

06 Mar 11:54
Compare
Choose a tag to compare

This is a big patch with new style computing (#1399) and landed to master regression tests

A lot of bugs are fixed

  • fixed scientific notation parsing in paths (d6f972c)
  • forbade invalid <style> type attribute in inlineStyles plugin (#1400)
  • fixed <style> support in removeHiddenElems plugin (#1399)
  • fixed noSpaceAfterFlags option support (0e02fd9)
  • fixed floatPrecision when extending default plugins (d58a7e6)
  • fixed <style> support when removing useless path commands (c21fef5)
  • fixed <style> support when combining path commands (ba7e9bd)
  • prevent removing filter primitive defaults (555a961)
  • prevent merging paths with markers (de4fd79)
  • prevent removing single point paths with markers (21c04e4)
  • keep empty <pattern> when at least one argument is present (0e6b0c4)
  • keep <marker> with display none (d3e3726)
  • preserve empty conditional processing attributes (a2b0e73)
  • preserve viewBox in nested <svg> (28c01cf)

435 of 526 regression tests are passing

Thanks to @XhmikosR @sk- and @TrySound

v2.2.0

01 Mar 22:33
Compare
Choose a tag to compare

Wow, two minor releases in a row. There is a big reason for that. We got a new logo! See it in readme. Big thanks to @DerianAndre.

There were also implemented brand new path data parser and stringifier (#1378 and #1387) to do more reliable transformations and produce smaller svg.

A cup of small fixes

  • fixed optimisation when stroke-linecap=round is specified (7901588)
  • prevented transform applying when inline style is present (79dbb4b)
  • apply transform to stroke-dasharray and stroke-dashoffset (dd37fcf)
  • fixed removing hidden elements when descendant enables visibility (d06747a)
  • fixed removing elements with zero opacity inside clipPath (9d67586)
  • fixed removing empty mask which can hide elements by id (d14315b)
  • fixed removing stroke-width when marker-end is specified (3639156)
  • fixed <tspan> inside <a> (091172a)

Thanks to @sk- @XhmikosR @deepsweet and @TrySound

v2.1.0

23 Feb 23:13
Compare
Choose a tag to compare

This release introduced two big changes

  • we forked sax parser to fix issues inaccessible from public api (https://github.com/svg/sax)
  • we added regression tests which already caught 4 bugs (WIP)

See fixed bugs

  • fixed empty <svg /> with enabled cleanupIDs plugin (9b97e06)
  • fail when file specified in --config flag does not exist or json string is specified (a855b40)
  • disabled convertStyleToAttrs by default (#1365)
  • preserve whitespace in elements containing text (#1220)
  • fixed removing xml:space="preserve" (776ec1e)
  • preserve whitespace in nested textual elements (9de471a)
  • keep empty <g> when filter attribute is specified (c1d5f0f)
  • fixed parsing xml entities (#1371 isaacs/sax-js#200)

Thanks to @XhmikosR @sk- @chromakode @devongovett and @TrySound

v2.0.3

20 Feb 16:22
Compare
Choose a tag to compare
  • reduced browser build size 1450kB -> 820kB (82778c8)
  • fixed adding empty <defs> by reusePaths plugin (#1201)
  • fixed reporting parsing errors (ea82cc2)
  • fixed convertEllipseToCircle plugin when rx or ry attributes are not specified (7f4e052)
  • fixed removing mask-type on <mask> (4490d62)
  • fixed removing elements when class is empty in removeElementsByAttr plugin (d9f68d3)
  • disable removing spaces in <path> by default to support many broken non-browser environments (#1353)
  • fixed error message in addAttributesToSVGElement plugin (c1edce4)

Thanks to @ChrisRu @XhmikosR @yisibl @TrySound

v2.0.2

19 Feb 09:24
Compare
Choose a tag to compare
  • added better docs (#1337)
  • removed unsafe usage of Buffer constructor (#1341)
  • fixed incorrect regexp in convertStyleToAttrs plugin (#1338)
  • fixed swallowing errors in config files (#1342)

Thanks to @XhmikosR and @TrySound

v2.0.1

18 Feb 15:11
Compare
Choose a tag to compare
  • fixed path intersection in mergePaths plugin (#1229)
  • fixed --indent flag in CLI (#1331)
  • fixed multipass option (#1332, #1177)
  • fixed plugins order (#1334)
  • detect .svg files in folder case-insensitively (#1316)

Thanks to @sk- @Brooooooklyn @strarsis @AlpayY @TrySound

v2.0.0

17 Feb 17:03
Compare
Choose a tag to compare

Happy to introduce SVGO 2.0. Package size was drastically reduced. Configuration
is heavily simplified. Node 10.13+ is required.

  • smaller install size
  • simplified config format
  • added browser ready es module bundle
  • API is synchronous
  • support only svgo.config.js for external configuration

Config changes

Since early versions plugins configuration was affected by yaml syntax.
Though it was not practial in json or javascript for writing and for internal
work.

plugins:
    - removeViewBox: true
    - removeAttr:
        attrs: '(fill|stroke)'
{
  plugins: [
    {
      removeViewBox: true
    },
    {
      removeAttr: {
        attrs: '(fill|stroke)'
      }
    }
  ]
}

In the new version plugins configuration is closer to internal representation.

{
  plugins: [
    {
      name: 'removeViewBox'
    },
    {
      name: 'removeAttr',
      params: {
        attrs: '(fill|stroke)'
      }
    }
  ]
}

In v1 full flag allowed to disable all default plugins and run only specified
in plugins list. In v2 it's default behaviour. To extend default plugins list
you can use extendDefaultPlugins utility.

{
  plugins: extendDefaultPlugins([
    {
      name: 'removeViewBox',
      active: false,
    }
  ])
}

Loading custom plugin by path was removed in favour of manual import or require.

+const customPlugin = require('./custom-plugin.js')
 {
   plugins: [
     {
       name: 'customPlugin',
-      path: './custom-plugin.js'
+      ...customPlugin
     }
   ]
 }

CLI changes

Painful coa was replaced with well maintained commander.

--enable and --disable flags are removed. In later versions we will explore
plugins setup via CLI.

Inlined json config is no longer suppored. CLI flags should be used instead.

--config="{multipass:true}"

By default SVGO CLI will search for svgo.config.js. --config flag allows
to specify js config with any name.

YAML and JSON configuration is no longer supported for the sake of simplicity
and less dependencies.

Node API changes

Initially SVGO was implemented with callback style api to fit sax recommendation.
Though in practice api was synchronous and allowed to access the result assigned
in callback right after optimisation.

For v1 callback style was replaced with promise api which cannot longer be run
synchronously. This was a pain point for many tools and required hacking svgo.

In v2 this pain is considered and api is now synchronous. No hacks necessary.

SVGO class is replaced with optimize function.

-const { SVGO } = require('svgo')
-const svgo = new SVGO({
-  // config
-  multipass: true
-})
-svgo.optimize(svgstring, { path: './file.svg' }).then(result => {
-  ...
-})
+const { optimize, extendDefaultPlugins } = require('svgo')
+optimize(svgstring, {
+  path: './file.svg',
+  multipass: true,
+})

Some tools require the same logic for resolving svgo config as SVGO CLI.

const { loadConfig, optimize } = require('svgo')
...
const config = await loadConfig()
optimize(svgstring, { path: './file.svg', ...config })

Browser ready bundle

There were a lot of request for this feature in the past.
Now tools like svgomg may use official and tested es module for browsers with optimize, extendDefaultPlugins and createContentItem support.

import {
  optimize,
  extendDefaultPlugins,
  createContentItem
} from 'svgo/dist/svgo.browser.js'

1.3.2 / 30.10.2019

30 Oct 11:01
Compare
Choose a tag to compare
  • Fixed TypeError: Cannot set property 'multipassCount' of undefined

1.3.1 / 29.10.2019

29 Oct 20:07
Compare
Choose a tag to compare
  • Updated CSSO version to 4.0.2 fixing the issue with empty semicolons ";;" in styles (thanks to @strarsis and @lahmatiy).
  • prefixIds plugin now runs only once with --multipass option (by @strarsis).
  • cleanupIDs plugin is prevented from producing a preserved ID, including one which matches a preserved prefix, when minifying (by @thomsj).

1.3.0 / 14.07.2019

14 Jul 16:45
Compare
Choose a tag to compare
  • Custom plugins now can be loaded from external js through path plugin param.
  • New plugin convertEllipseToCircle to convert ellipse with equal radius measures to circle (by @tigt).
  • New plugin sortDefsChildren for improved compression (by @davidleston).
  • SVGO now removes unnecessary spaces after arcto path command flags.
  • removeDimensions plugin now adds viewBox if it's missing (by @adipascu).
  • Fixed removeUnusedNS not counting attributes in <svg> tag itself.
  • Fixed an issue with incorrect processing multiple images (by @cyberalien).
  • Fixed an error with incorrect converting multiple segmented curve to an arc.
  • Fixed an error with matrix decomposition in convertTransform due to rounding error leading to illegal value.
  • Added force option for mergePaths plugin (by @goyney).
  • Added options to prefixIds plugin for selectively prefixing IDs and/or classes (by @strarsis).
  • Exported config function (by @1000ch).