Summary
This chapter explained how the build system can be leveraged to produce minified and concatenated web assets. These assets can then be safely cached by web browsers while giving you the comfort of writing the client-side code in a modular way and using higher-level languages to compile to JavaScript and CSS.
The assets processing pipeline that we set up in this chapter can be illustrated using the following diagram:
The compilation plugins, sbt-less and sbt-coffee, compile the a.less
module (that depends on a b.less
module) into a single a.css
module and the modules, a.coffee
and b.coffee
, into the a.js
and b.js
modules, respectively. Then, the concatenation plugin, sbt-rjs, concatenates the a.js
and b.js
modules into a single a.js
module (it is worth noting that the CSS concatenation is already performed by the less compiler but that the RequireJS optimizer also processes .css
files to minify them). The compression plugin, sbt-gzip, produces a compressed file for each artifact. Finally...