1
0
mirror of https://github.com/svg/svgo.git synced 2025-07-04 16:42:27 +03:00
Commit Graph

5 Commits

Author SHA1 Message Date
cb7e9be623 Add warning about enabling plugins in presets 2021-11-02 10:33:46 +03:00
3d22a5b23d Refactor prefixIds (#1561)
Ref https://github.com/svg/svgo/issues/1499

- migrated to visitor plugin api
- covered with tsdoc
- made the plugin idempotent as requested a few times
  Now even manually running svgo a few times will not duplicate
  prefix in ids and classes
- run each plugin test twice to see which plugin need to run many times
  ideally idempotent plugins will allow to get rid of multipass option in v3
2021-09-13 16:16:38 +03:00
77102ed096 Add better parser errors (#1553)
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 |
```
2021-09-12 01:09:10 +03:00
e8321f0c27 Allow choosing EOL and appending final newline (#1546)
Addresses #951

Adds the following options to js2svg and CLI:

- eol — can be set to `lf` or `crlf`. If unspecified, js2svg uses the
  platform EOL.
- finalNewline — defaults to false. If true, js2svg ensures any SVG
  output has a final newline.

Tests added to cover both options.
2021-09-11 21:08:01 +03:00
07f8d606e0 Implement preset-default plugin (#1513)
I saw complaints about `extendDefaultPlugins` api

- it cannot be used when svgo is installed globally
- it requires svgo to be installed when using svgo-loader or svgo-jsx
- it prevents using serializable config formats like json

In this diff I introduced the new plugin which is a bundle of all
default plugins.

```js
module.exports = {
  plugins: [
    'preset_default',
    // or
    {
      name: 'preset_default',
      floatPrecision: 4,
      overrides: {
        convertPathData: {
          applyTransforms: false
        }
      }
    }
  ]
}
```
2021-08-13 19:07:08 +03:00