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 ...
Get Smashing CoffeeScript now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.