Introducing JAM

Jason's Asset Manager (JAM) is shell script for combining and minifing a website's front end assets. Essentially, JAM is a configuration manager for YUI Compressor. It works by passing the name of a configuration file as a command line argument when calling JAM. The configuration file has three settings; COMPILETO, REF and FILES.

The first setting is COMPILETO. COMPILETO tells JAM where to write the resulting asset files.

The second setting is $REF, this tells JAM whether or not it should create and/or write to a file called latest.txt. The latest.txt file contains the name of the configuration file prepended to a timestamp. This is the format of the file names created by JAM [configuration]-[timestamp].[css/js].

The final setting is simply called FILES, this is the list of files to be combined and minified.

Below is the current configuration I use for jasonsnider.com.


#!/bin/bash
## Defines the path to which the assets will be compiled
COMPILETO="/var/www/jasonsnider.com/tinker/themes/Jsc/webroot/assets/compiled/"

REF=1

## Print specific style sheets need to be called last
FILES="
    /var/www/jasonsnider.com/tinker/themes/Jsc/webroot/assets/vendors/normalize/2.1.2/normalize.css
    /var/www/jasonsnider.com/tinker/themes/Jsc/webroot/assets/vendors/h5bp/css/main.css
    /var/www/jasonsnider.com/tinker/themes/Jsc/webroot/assets/css/default.css
    
    /var/www/jasonsnider.com/tinker/themes/Jsc/webroot/assets/vendors/h5bp/css/print.css
    /var/www/jasonsnider.com/tinker/themes/Jsc/webroot/assets/css/print.css
"

Configuration files are expected to be placed on the jaws/config path. Personally I like to use short but relavent names for my configuration files. I would likely name the configuration file for jasonsnider.com something like jsc.

Then to recompile my assets I would run the following from the commandline (assumes JAWS was extracted to ~).


cd ~/jaws && ./build jsc

The CLI will then display the name of any files created, you can copy and paste these file names into your application or have your application read from latest.txt. At this point your application will be using the newly compiled assets files.

Download | Fork me on GitHub