Using CoffeeScript with Node.js
Node.js is an environment that runs JavaScript on the server side. We're already using it to run our CoffeeScript compiler! However, Node is also popular for running server applications. It should be no surprise, then, that we can configure server-side Node applications to compile CoffeeScript for client-side code.
We'll build a simple server using Express, a popular MVC framework for Node. To compile our CoffeeScript, we'll use a Node package that provides an asset pipeline. This is some code that takes assets, such as scripts and style sheets, and compiles and prepares them for consumption by a browser. Once we have that set up, we'll port our pet shop application to try it out.
Even though we'll be detailing the process with Express, this system will work on many Node applications. Our asset pipeline package works as a Connect middleware. This is a common format for building interoperable plugins to web servers in Node. If your chosen server supports Connect...