ben-eb/gulp-svgmin

Files compress multiple times.

torrfura opened this issue · 2 comments

I tried using svgmin for minifying (i.e clean up) svg's I use for generating icon fonts. Problem is when you run svgmin on the same file a couple of times, it compresses even further, making the svgs messed up.

Here's the result of the same .svg, run twice.

First run:

<svg xmlns="http://www.w3.org/2000/svg" width="512" height="512" viewBox="0 0 512 512"><path d="M405.346 333.738L265.914 112.206c-1.502-2.385-4.204-3.847-7.122-3.852h-.017c-2.91 0-5.61 1.45-7.12 3.823l-140.53 221.267c-1.557 2.452-1.607 5.512-.133 8.005 1.47 2.496 4.243 4.035 7.248 4.04l279.962.265h.01c2.995 0 5.763-1.536 7.24-4.024 1.476-2.487 1.44-5.54-.105-7.995zm-128.293-149.3l-3.858 82.78H242.48l-1.733-82.91 36.306.13zm-19.425 136.086c-10.876 0-19.694-8.822-19.694-19.7s8.818-19.698 19.694-19.698c10.882 0 19.698 8.822 19.698 19.7s-8.817 19.698-19.698 19.698z"/></svg>

Second run:

<svg xmlns="http://www.w3.org/2000/svg" width="512" height="512" viewBox="0 0 512 512"><path d="M405.346 333.738L265.914 112.206c-1.502-2.385-4.204-3.847-7.122-3.852h-.017c-2.91 0-5.61 1.45-7.12 3.823l-140.53 221.267c-1.557 2.452-1.607 5.512-.133 8.005 1.47 2.493 4.243 4.032 7.248 4.04l279.962.262h.01c2.995 0 5.763-1.536 7.24-4.024 1.476-2.488 1.44-5.54-.105-7.996zm-128.293-149.3l-3.858 82.78H242.48l-1.733-82.91 36.306.13zm-19.425 136.086c-10.876 0-19.694-8.822-19.694-19.7s8.818-19.698 19.694-19.698c10.882 0 19.698 8.822 19.698 19.7s-8.817 19.698-19.698 19.698z"/></svg>

I'm not really sure what to suggest here, other than don't use it on already compacted svg files if it is an issue for you. 😄

You might like to open an issue upstream if you think its relevant enough. The other solution might be to disable some of the modifications if you think they are negatively impacting icons after repeated transformation, such as mergePaths.

I'm going to go ahead and close this as it's not really related to this wrapper which essentially is just delegating to SVGO. However, there have been a few fixes upstream with a new version released as well, so I will release this with the updated library; perhaps that might help this issue.

See release 0.4.8 on npm. 😃