You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm currently using SASS to provide styles to an HTML to print (PDF) workflow. I would like to be able to use the provided stylesheet to web pages as well. While this works in one direction using media queries, the other way doesn't since the PDF rendering mechanism ignore @media print queries.
Solution
Provide a mechanism (for the JS API) to able to pass a media query to sass.compile, as in sass.compile(scssFilename, 'print') that would only return the flattened stylesheet with resolved attributes according to the @mediaprint. That is screen related / only styles won't be part of the result. Same should be possible for the CLI interface.
Possible alternatives
Not yet checked, but maybe this could be done via PostCSS (and a hand crafted plugin) as well.
Disclaimer: Even though this uses the JS API as an example, it shouldn't be limited to this specific API. But needs to be added to the core first. If this is the wrong repository for such a request please move.
The text was updated successfully, but these errors were encountered:
I suppose you can split the media=print stylesheet as a dedicated sass/css file (without @media in the file), and just link it separately in the HTML file:
If you really, really want to have everything in the same input file, and create multiple outputs by filtering based on certain rules, that's exactly what PostCSS is designed for.
Use case
I'm currently using SASS to provide styles to an HTML to print (PDF) workflow. I would like to be able to use the provided stylesheet to web pages as well. While this works in one direction using media queries, the other way doesn't since the PDF rendering mechanism ignore
@media print
queries.Solution
Provide a mechanism (for the JS API) to able to pass a media query to
sass.compile
, as insass.compile(scssFilename, 'print')
that would only return the flattened stylesheet with resolved attributes according to the@media
print
. That isscreen
related / only styles won't be part of the result. Same should be possible for the CLI interface.Possible alternatives
Not yet checked, but maybe this could be done via PostCSS (and a hand crafted plugin) as well.
Disclaimer: Even though this uses the JS API as an example, it shouldn't be limited to this specific API. But needs to be added to the core first. If this is the wrong repository for such a request please move.
The text was updated successfully, but these errors were encountered: