node.jsexpressnode.js-connect

NodeJS: Jade, Coffee, Scss assets rendered without writing to disk


I'm looking for some middleware modules that allow me to render ".css" from ".scss", ".html" from ".jade", ".js" from ".coffee" on the fly without rendering to disk.

Every module I've encountered so far wants to write to disk before serving it instead of just streaming it.

Obviously this is only for local development since I'm not interested in dealing with file-revving and caching problems.


Solution

  • Answering my own question here:

    The middleware to use is compile-middleware. Works fine by default with connect, but with express I had to modify it in order to not write headers (ugly i know, but time waits for no one) : https://github.com/airtonix/compile-middleware

    implementation: https://gist.github.com/airtonix/9601224

    Original Credit goes to (You should try using this one first): https://github.com/shinohane/compile-middleware