O'Reilly logo

Smashing CoffeeScript by Alex Hudson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

CHAPTER 9

Building Resources with Cake and Hem

As a compiled language, CoffeeScript source files are not the sort of thing that can be deployed directly, though actually, in all but the simplest JavaScript applications, the source is never deployed directly. To provide end users with the best performance, multiple processes are generally run over source files, which at least merges them into fewer, larger files. These processes often “minify” the files, too, by removing as much redundant information as possible.

This chapter explores a few basic, useful tools: cake, stitch, and hem. As well as covering the processes as they apply to CoffeeScript source files, the chapter explains how you can use these tools to build other resources within a project, making the whole thing ready for production deployment.

Tasks and the Cakefile

Not long after CoffeeScript was initially developed, there was a recognized need for some kind of build tool. Build tools, such as make and ant, are commonplace on other platforms. In general, build tools provide a few key features:

The ability to express a dependency among different source files so that they can be included together

An awareness of when source files were last modified so that they’re not recompiled without reason

Options to compile part of a project rather than the whole thing

The build tool for CoffeeScript took many cues from the popular make tool, and indeed was named after it—it’s called cake. And, by general consensus, although ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required