Svgo Versions Save

⚙️ Node.js tool for optimizing SVG files

v2.2.1

3 years ago

This is a big patch with new style computing (https://github.com/svg/svgo/pull/1399) and landed to master regression tests

A lot of bugs are fixed

435 of 526 regression tests are passing

Thanks to @XhmikosR @sk- and @TrySound

v2.2.0

3 years ago

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 (https://github.com/svg/svgo/pull/1378 and https://github.com/svg/svgo/pull/1387) to do more reliable transformations and produce smaller svg.

A cup of small fixes

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

v2.1.0

3 years ago

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

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

v2.0.3

3 years ago

Thanks to @ChrisRu @XhmikosR @yisibl @TrySound

v2.0.2

3 years ago

Thanks to @XhmikosR and @TrySound

v2.0.1

3 years ago

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

v2.0.0

3 years ago

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'

v1.3.2

4 years ago
  • Fixed TypeError: Cannot set property 'multipassCount' of undefined

v1.3.1

4 years ago
  • 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).

v1.3.0

4 years ago
  • 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).