Time for action – creating a release script
The easiest way to prepare your JavaScript for release is to create a script that can be run from the command line. In this example we will use the YUI Compressor, but it works almost identically for Closure. The only difference is the command-line parameters. In this example we create a command-line script that can be run from the Windows command line, that will take the Piano Hero application we wrote in Chapter 7, Piano Hero, and package it up for release. You can find the code for this section in Chapter 10/example10.1
.
Before we start, we need to define a folder structure for the application. I like to create a base folder for the application that contains a src
folder and a release
folder. The base folder contains the command-line batch script. The src
folder contains all of the source code and resources. The release
folder will contain the compressed JavaScript file and all other resources necessary to run the application:
Now let...