import postcss from 'postcss'
import sortMediaQueries from 'postcss-sort-media-queries'
const style = `
@media screen and (width <= 1250px) {
.a {
color: #00FF00;
}
}
@media screen and (width <= 250px) {
.b {
color: #FF0000;
}
}
@media screen and (width >= 1250px) {
.a {
color: #00FF00;
}
}
@media screen and (width >= 250px) {
.b {
color: #FF0000;
}
}
`
postcss([
sortMediaQueries({
sort: 'mobile-first',
}),
])
.process(style)
.then((result) => {
console.log(result.css)
})
@media screen and (width <= 250px) {
.b {
color: #FF0000;
}
}
@media screen and (width >= 250px) {
.b {
color: #FF0000;
}
}
@media screen and (width <= 1250px) {
.a {
color: #00FF00;
}
}
@media screen and (width >= 1250px) {
.a {
color: #00FF00;
}
}
@media screen and (width >= 250px) {
.b {
color: #FF0000;
}
}
@media screen and (width >= 1250px) {
.a {
color: #00FF00;
}
}
@media screen and (width <= 1250px) {
.a {
color: #00FF00;
}
}
@media screen and (width <= 250px) {
.b {
color: #FF0000;
}
}