PostCSS Custom Media runs in all Node environments, with special instructions for:
Options
preserve
The preserve option determines whether custom media and atrules using custom media should be preserved in their original form.
@custom-media --small-viewport (max-width: 30em);
@media (--small-viewport) {
/* styles for small viewport */
}
/* becomes */
@custom-media --small-viewport (max-width: 30em);
@media (max-width: 30em) {
/* styles for small viewport */
}
@media (--small-viewport) {
/* styles for small viewport */
}
importFrom
The importFrom option specifies sources where custom media can be imported from, which might be CSS, JS, and JSON files, functions, and directly passed objects.
@media (max-width: 30em) {
/* styles for small viewport */
}
@media (--small-viewport) {
/* styles for small viewport */
}
Multiple sources can be passed into this option, and they will be parsed in the order they are received. JavaScript files, JSON files, functions, and objects will need to namespace custom media using the customMedia or custom-media key.
The exportTo option specifies destinations where custom media can be exported to, which might be CSS, JS, and JSON files, functions, and directly passed objects.
Multiple destinations can be passed into this option, and they will be parsed in the order they are received. JavaScript files, JSON files, and objects will need to namespace custom media using the customMedia or custom-media key.