-
Notifications
You must be signed in to change notification settings - Fork 11.9k
Closed
Labels
P5The team acknowledges the request but does not plan to address it, it remains open for discussionThe team acknowledges the request but does not plan to address it, it remains open for discussionfeatureIssue that requests a new featureIssue that requests a new featurehelp wanted
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)
MurhafSousli, phaux and matheo
Metadata
Metadata
Assignees
Labels
P5The team acknowledges the request but does not plan to address it, it remains open for discussionThe team acknowledges the request but does not plan to address it, it remains open for discussionfeatureIssue that requests a new featureIssue that requests a new featurehelp wanted