-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
convertcolors.js plugin: shorthex behavior is true even if set to false #933
Comments
It should work: Lines 92 to 95 in 898f0a2
UPD.
That may be a reason. How do you pass a config? |
I believe the code section you cite does the opposite of what I want--I want to preserve long hex. I have tried commenting out that section of the config and it still converts to short hex. If a config can be passed (the CLI options given by |
In my setup, and perhaps in the code base itself, something else is overriding the I think what is overriding it is another plugin setting. I edited |
I managed to narrow it down to the minifyStyles plugin. Apparently, that plugin also converts the colors. If you disable minifyStyles, the colors are left as is. |
Thanks for narrowing that down. Coincidentally the other day I reworked something in my toolchain to work with short hex also (which might really be what was going on when I opened this issue--I think another tool didn't work with short hex). Still, if anyone else wants to avoid short hex, what you uncovered might help toward that. |
I don't use the |
It's not really a problem I think. |
That's why you need to disable names2hex, probably it's hard coded as "black = #000" |
The option should work, I would assume the config may have been passed wrong for the version of SVGO you were using, or wasn't exporting correctly. This config should work:
module.exports = {
plugins: [
{
name: "preset-default",
params: {
overrides: {
convertColors: {
shorthex: false
}
}
}
}
]
}
Thanks for raising this, I'll work on it soon.
That's because the
|
How do I ensure svgo does not shorten hex color codes?
I'd like to know whether it is possible and how to change this option from a CLI parameter, but this is what I have tried which I believe has formerly worked in the
convertColors.js
config file to not convert e.g.ffffff
hex color fill tofff
; in theconvertColors.js
config file:I believe the relevant setting there is
shorthex: false,
?It has no effect one way or the other toggling it from true to false. Honestly I wonder if the config file is used at all. However I alter it, and even if I delete it, the conversion comes out the same.
The text was updated successfully, but these errors were encountered: