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 perceived page performance.
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 scan 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->addCss('grid.css', 'layout.css'); // Will _not_ work $this->AssetCompress->addCss($file, 'layout.css');
If you only want to generate files defined in the Configuration file, you can use:
Console/cake AssetCompress.AssetCompress build_ini
If you only want to generate files defined dynamically with the helper, you can use:
Console/cake AssetCompress.AssetCompress build_dynamic
If you'd like to do both at once, you can use:
Console/cake AssetCompress.AssetCompress build
All generated files will be put into the configured cache directories. By default, the build shell will skip re-building files that don't appear to have any changes. The shell compares the mtime of the build file, and the component files. If all of the components have an older time than the build file, the build file will not be regenerated. You can suppress this behavior using the
Console/cake AssetCompress.AssetCompress build --force
You can use alternate config files by using the
Console/cake AssetCompress.AssetCompress build --config path/to/config/file.ini
You may want to clear the generated files. Only files defined in the Configuration file will be cleared. Use the following:
Console/cake AssetCompress.AssetCompress clear