Closed Hilzu closed 6 years ago
You are 100% correct. And thank you for providing such thorough details.
PostCSS Color Function does not support Custom Properties. Therefore, it relied on the developer not supporting Custom Properties in their CSS.
You have a few choices:
preserve
in this plugin and do not support Custom Properties in the browser.postcss-color-function
developers to have the contents of color()
find and replace Custom Properties. This is the best option if you don’t want to change your CSS.color-mod()
which supports variables, and replace your instances of color(
with color-mod(
. FWIW, color-mod
is the real name of this highly speculative feature)I see. For now I'll disable the preserve option. Looks like I have to evaluate using the color plugin at some point. I swear the function was called color
in the spec at some point and not color-mod
. 😅
Thank you for your explanation!
Yes, it was called color()
2 or 3 years ago, but that name is used by another, real color()
function which controls colorspace and ships in Safari. I raised this issue in the fall of last year: https://github.com/ianstormtaylor/css-color-function/issues/29
I have CSS like this:
I'm using the
postcss-color-function
plugin to transform the color function. I've configured custom-properties to run before the color function plugin as recommended in its readme.With the new
postcss-custom-properties
that has thepreserve
option set totrue
generates this output that doesn't work in any browser:Here's a runkit notebook that generates this same output: https://runkit.com/hilzu/postcss-custom-properties-with-preserve-enabled
Is it so that the preserve option can't be used when using color functions with variables?