Skip to content
markstory edited this page Jun 11, 2011 · 11 revisions

Asset Compress includes a Shell that can be used to create and clear build files. You can realize considerable performance boosts by using the shell to generate compiled assets before you deploy. Static assets that are minified and concatenated reduce page size and improve actual and percieved page performance.

Building files

Using the shell to build files is ideal when you want to integrate with a build or deployment script. The build task will generate all the assets defined in your Configuration file as well as tokenize and scans all your view files for asset helper calls. It will keep track of which files go into each build file and generate all the build files at once. One limitation is that files to be included into build files must use strings for the filenames; variables will not be included.

// Will work
$this->AssetCompress->css('file', 'target');
      
// Will _not_ work
$this->AssetCompress->css($file, 'target');

If you only want to generate files defined in the Configuration file, you can use:

cake asset_compress.asset_compress build_ini

If you only want to generate files defined dynamically with the helper, you can use:

cake asset_compress.asset_compress build_dynamic

If you'd like to do both at once, you can use:

cake asset_compress.asset_compress build

All generated files will be put into the configured cache directories. You can run the build task with

Clearing build files

You may want to clear the generated files. Only files defined in the Configuration file will be cleared. Use the following:

cake asset_compress.asset_compress clear
Clone this wiki locally