-
I want to discard all .foo { width: 100px; }
@media print {
.bar { width: 50mm; }
}
.baz { width: 200px; } I want the result to be I have experimented with visitors, and successfully identified the print queries with a Is there a way to do this? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
I found the solution. const { code } = transform({
filename: 'test.css',
code: Buffer.from(styleString),
minify: true,
visitor: {
Rule(rule) {
if (rule.type === 'media') {
if (rule.value.query.mediaQueries.some((q) => q.mediaType === 'print')) {
return [];
}
}
return rule;
},
},
}); |
Beta Was this translation helpful? Give feedback.
I found the solution.
MediaQuery
was the wrong visitor here, but aRule
visitor did the trick. Here is my solution: