postcss-custom-properties icon indicating copy to clipboard operation
postcss-custom-properties copied to clipboard

Variable replacement failure

Open geovezir opened this issue 6 years ago • 1 comments

[email protected]

CSS input

:root {
  --color1: #000000;
  --color2: #FFFFFF;
}

.success {
  background-image: linear-gradient(var(--color1), var(--color2));
}

.fail {
  background-image: linear-gradient(var(--color1),var(--color2));
}

CSS ouput ( preserve: false )

.success {
  background-image: linear-gradient(#000000, #FFFFFF);
}

.fail {
  background-image: linear-gradient(#000000,var(--color2));
}

The variable is left unchanged if there is no space between the comma and the "var" keyword.

geovezir avatar Jun 27 '19 17:06 geovezir

This especially effects SCSS chains in webpack, as sass-loader/node-sass defaults to the ,var output. A workaround for this is to add outputStyle: "expanded", to the sassOptions to ensure whitespace exists in between.

merrywhether avatar Oct 26 '19 16:10 merrywhether