Split the specified css rules into another file.
npm install postcss-split-css --save-dev
splitCss = require("postcss-split-css");
postcss([
splitCss({
filter: [".lte_ie9", ".ie9", ".ie8"],
output: {
from: __dirname + "/src",
dist: __dirname + "/dist",
subfix: ".ie",
append: "#__generated__{content:'" + new Date().toISOString() + "'}"
}
})
]);
Before:
/* style.css */
body{
color: #000;
}
.lte_ie9 div{
color: #f0f
}
.ie8 div{
color: #f00
}
div {
color: #ff0;
}
After:
/* style.css */
body{
color: #000;
}
div {
color: #ff0;
}
/* style.ie.css */
.lte_ie9 div{
color: #f0f
}
.ie8 div{
color: #f00
}
Inspired by PostCSS Filter Rules