When running this plugin on an SVG with an empty block in the CSS, it
would apply it to the matched elements by adding an empty `style`
attribute. See the test for an example.
This resolves that by just dropping the declaration if it's empty.
Detects if a redundant linearGradient or radialGradient is used with
only a single stop, which effectively means a solid color.
If this is found, just remove the gradient and replace references to it
with the color of the first and only stop defined.
The regression-test GitHub Action was failing for all pull requests due
to not handling the gzipped archive properly.
This resolved it by piping the response body to zlib#createGunzip
first. Also updates the relevant dependencies.
Signed-off-by: Seth Falco <seth@falco.fun>
Co-authored-by: strarsis <strarsis@gmail.com>
Co-authored-by: Bogdan Chadkin <trysound@yandex.ru>
Ref https://github.com/ai/nanocolors#nano-colors
Nanocolors is deprecated in favour of picocolors to avoid drama.
All dependencies already migrated. Also fixed one vulnerability.
The main change is step away from named exports and dual modules
support in favour of smaller package.
nanocolors checks for --color and --no-color flags to force or disable
output coloring. Which can be used instead of strip-ansi package which
btw introduced vulnerability recently.
Ref https://github.com/svg/svgo/issues/1579
In config of course. Projects with type:module can now use modules to
export config
```js
export default {
plugins: []
}
```
Also added support for resolving svgo.config.mjs and svgo.config.cjs.
Moved loadConfig tests to svgo-node tests.
mjs test is skipped for now in node 10, just don't use modules there
Ref https://github.com/ai/nanocolors
Nanocolors is the new player in color libraries. And it's perfectly
packaged as all @ai packages. Colorette is already replaced even
in transitive dependencies.
Old SVGO errors were not very helpful. Packages like cssnano
(postcss-svgo) had to deal with a lot of issues which are hard to debug
with old errors.
```
Error: Error in parsing SVG: Unquoted attribute value
Line: 1
Column: 29
Char: 6
File: input.svg
```
New errors are more informative and may solve many struggles
```
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 |
```
Mocha doesn't have a lot of features provided by jest.
There is a great assertion library out of the box.
And the most cool feature is inline snapshots.
Mocha also hides errors which makes debugging a nightmare sometimes.
Remove 5 deps from production install:
`ansi-styles`, `supports-color`, `color-convert`, `has-flag`, `color-name`.
Also reduce deps when using PostCSS and SVGO together, since PostCSS
uses colorette.
Tested with `yarn install svgo`.
A lot of new sources of regression tests may come and it's important to
make debug simpler.
Now regression-extract.js downloads and write svg files into
test/regression-fixtures. regression.js run each svg in this folder.
Mismatched svg diff is written into test/regression-diffs.