clean-css / clean-css-cli

The command line interface to clean-css CSS optimizer
MIT License
302 stars 17 forks source link

Read CSS file from stdin #75

Closed SabrinaJewson closed 2 years ago

SabrinaJewson commented 2 years ago

Would it be possible to run cleancss such that it reads the CSS file from the standard input instead of a named file? My CSS file is being generated dynamically it would be easier if I could avoid having to write out to a temporary file. I tried cleancss - but it doesn't seem to work:

ERROR: Ignoring local @import of "-" as resource is missing.
jakubpawlowicz commented 2 years ago

Hi @SabrinaJewson - is piping your CSS file to clean-css an option, e.g. echo 'a{color:#f00}' | cleancss? This is one of the ways clean-css is tested, e.g. https://github.com/clean-css/clean-css-cli/blob/master/test/binary-test.js#L71 - pipedContext is defined next to the top of the file.

SabrinaJewson commented 2 years ago

oh my, I didn't test that - I just saw it error out with no args and assumed it doesn't support it at all 😅

Sorry for the trouble, it works perfectly! Thank you very much.

jakubpawlowicz commented 2 years ago

No problem, cheers!