I'm trying to pipe request output into clean-css to minify and then provide it as a response. The example app in question is built on restify.
Sample Objective Code :
var url = "http://www.example.com/css/style.css";
request.get(url).pipe(minify()).pipe(res);
How can I define the minify() function to accept stream and return one. I've tried dozens of packages, none worked. Help would be much appreciated!
You can create a Transform stream. It gets the CSS code from the stream created by
request.get
, does the minification magic and returns the minified CSS.Here's a working example: