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 ...

Get CoffeeScript Application Development now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.