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

51 Commits

Author SHA1 Message Date
65b6bf4c16 Refactor svg stringifier (#1593)
- rewrote prototype class with functions
- covered with tsdoc
- added a few TODOs for v3
2021-10-07 14:06:55 +03:00
7601b17ab5 Rename js2svg to stringifier 2021-10-01 14:44:17 +03:00
6e23b9cf56 Cover svg parser with tsdoc (#1584)
Moved to lib/parser.js. The code will be slightly simpler
when JSAPI will be removed in v3.
2021-09-23 21:45:22 +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
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
21d24006fd Remove the executable flag from files. (#1439) 2021-03-20 20:46:26 +03:00
2458b70f31 Remove licenses 2021-03-09 23:40:36 +03:00
71e47370bd Format lib with prettier (#1386)
Note: review with hidden whitespaces
2021-02-28 10:56:16 +03:00
ea82cc2880 Report parsing errors with filename 2021-02-20 00:59:54 +03:00
efa62c8e30 Fix multipass (#1332)
Ref https://github.com/svg/svgo/issues/1330 https://github.com/svg/svgo/issues/1148 https://github.com/svg/svgo/issues/1133 https://github.com/svg/svgo/pull/1227 https://github.com/svg/svgo/issues/985 https://github.com/svg/svgo/issues/943
Took tests from https://github.com/svg/svgo/pull/1177
2021-02-18 14:12:27 +03:00
a6f14018ee Implement loadConfig utility (#1328)
Ref https://github.com/svg/svgo/issues/1327

Config file now can only be js. `svgo.config.js` is searched by default.
Otherwise any js module specified in `--config` cli flag.

Config loader is exposed in entry point as `loadConfig(configFile, cwd)`.
2021-02-16 19:11:13 +03:00
b1dafc6780 Implement default plugins and plugins list extending 2021-02-15 22:20:05 +03:00
c9c7871e0d Simplify svgo api (#1325)
Dropped SVGO class and provided "optimize" function with svg and config
as inputs and "createContentItem".
2021-02-15 18:32:50 +03:00
225bfbb053 Move config processing into optimize 2021-02-15 16:57:01 +03:00
1dc5ee3ee1 Make optimize synchronous (#1322)
Ref https://github.com/svg/svgo/issues/1015

Looks like `sax` is synchronous and we do not need to listen "end"
event. This allows to avoid all callbacks and make `optimize` method
synchronous.
2021-02-14 14:59:50 +03:00
72db8ebbbf Change wording of API doc comment 2019-11-02 12:14:38 +03:00
99d9c3c13a Default info on SVGO.optimize API 2019-10-30 13:52:26 +03:00
71c7fe74b9 Add multipassCount to info object passed to the plugins.
Use info object to skip subsequent passes in prefixIds plugin to prevent unintended, multiple prefixing.
2019-10-29 22:50:59 +03:00
d3e91418aa Export config function to enable to use 2019-07-13 22:51:31 +03:00
dfcc145d5a Fix crash when ‘info’ is absent
Fix #1030
2018-09-17 11:40:20 +03:00
62f67dee29 Return the path, so it can be used to overwrite the file with the optimized version 2018-09-15 14:46:45 +03:00
3e2fd44a17 feat: offer ES module interop default export (#934) 2018-09-15 14:44:17 +03:00
91d98106d4 Add prefixIds plugin (#700)
Add prefixIds plugin
2017-10-23 22:14:43 +03:00
51832d4c8a allow datauri option on js api 2017-06-02 17:34:03 -04:00
d74f6a0e2f Promisify SVGO 2017-03-25 23:46:43 +03:00
5132900904 Use explicit file types
It's good practice to declare the file type being required. This will help svgo play nice with JSPM. Additionally, one of the requires was already declaring its file type. So, this PR adds consistency, too.
2016-02-22 21:28:29 -08:00
9cdb046383 Improved parser error handling.
Show output error position. Resolves #482
2016-02-08 00:36:56 +03:00
e21f8d0e64 Better config error handling. Resolves #466 2016-02-08 00:00:17 +03:00
30237018ef make passes to be independent from each other 2014-11-05 16:58:20 +03:00
e0cf16962d Updated banner (thx to @shinnn) 2014-11-05 00:06:06 +03:00
943f5fab57 add ability to enable multipass 2014-11-01 00:03:02 +03:00
842f0d1b74 expose jsAPI as factory method 2014-08-28 20:51:11 +06:00
9e9f7d0cd2 better error handling 2013-04-15 15:32:51 +03:00
2dea171f8e replace default config with full: true 2013-04-11 19:51:29 +03:00
a2da6fe894 CONFIG.extend() + CONFIG.replace() + tests 2013-04-10 18:12:14 +03:00
2816424ed7 global refactoring dump 2013-04-09 22:06:27 +03:00
74bbdb46cc lib/svgo: store elapsed time in result object 2012-12-17 22:31:28 +02:00
5485010269 'use strict' motherfucker! do you use it?! 2012-11-27 22:51:31 +02:00
d35cec2900 lib/svgo: rename 'startBytes' to 'inBytes' and 'endBytes' to 'outBytes (close #53) 2012-11-23 23:56:33 +04:00
e2f604d5d7 lib/svgo: fatal and stupid error in stream chunks concatenation (fix #40) 2012-11-15 18:34:21 +02:00
b083c8e2e7 lib/coa: batch folder optimization (close #29) 2012-11-10 19:53:42 +02:00
639eecf20b lib/svgo: jsdoc corrections; update README 2012-11-09 19:04:07 +02:00
1b296adc7e lib/svgo: global API refactoring (close #37); temporarily remove PhantomJS and --test (close #38) 2012-11-09 18:54:00 +02:00
aa10a8b5de lib/svgo/ 2012-11-09 14:21:06 +02:00
354925f896 minor jsdoc corrections 2012-10-28 00:32:41 +03:00
50a8c8af20 allow to do a multiple optimizations with one init (close #25) 2012-10-26 23:46:09 +03:00
aa3fa83c10 Revert to 0d32aa9f6f 2012-10-25 17:31:54 +03:00
3e3e53bc71 lib/svgo: allow to do a multiple optimizations with one init (close #25) 2012-10-25 09:42:11 +03:00
7699b52169 add --pretty option; config structure refactoring 2012-09-30 11:01:19 +04:00
653bce7e09 massive jsdoc updates 2012-09-28 17:53:29 +04:00