Closed
Description
- [ X ] feature request
Desired functionality.
Css variables should degrade gracefully on older browsers by having a fallback. This post css plugin does exactly that when started with the option preserve: true
. More generally I believe the cli should support the css cutting edge with fallback thanks to cssnext
. However variables is what this request is about.
Why ?
If css variable is not supported by a browser it will simply be ignored, meaning that a bunch of css statements won't be applied.
Example
This
:root {
--color: red;
}
div {
color: var(--color);
}
should compile to this:
:root {
--color: red;
}
div {
color: red;
color: var(--color);
}
Here is an example that would do just that:
// dependencies
var fs = require("fs")
var postcss = require("postcss")
var customProperties = require("postcss-custom-properties")
// css to be processed
var css = fs.readFileSync("s.css", "utf8")
// process css using postcss-custom-properties
var output = postcss()
.use(customProperties({ preserve: true }))
.process(css)
.css
console.log(output)