AssetCompress 0.3 released

Today, I tagged the 0.3 release for my AssetCompress plugin. A few new features have been added, and several issues resolved. You can get the code from github

Build tool

The AssetCompress shell is now able to generate all the build files that are named in your project. This is great for integration with build/deployment scripts. You use it by calling cake asset_compress.asset_compress build. The plugin will scan all of your view files for any uses of the helper, and generate the resulting build files. Currently it rebuilds all the CSS and JS at once. In the future I hope to add the ability to build only CSS or Javascript files, and only particular files.

Auto named builds

Some people have had issues with build file naming, and keeping names unique across an application. As of 0.3 if no build target is named AssetCompress, will use an md5() of all the component files for the build name. You can create multiple automatically named build files, by using the :hash- prefix for your build files.

Basic filters included

Thanks to some contributions, there are now built-in filters for CssMin, JsMin and YUICompressor. Using these filters will help compact your build files even more, reducing response time.

A big thanks to everyone who opened tickets and submitted ideas/patches for this plugin. I’m really happy that it has turned out as well as it has. The future roadmap includes a rebuild of how pre-processing is done, so DSL’s like LESS can be integrated, and a more improved build shell.

Comments

Thanks Mark. We use your earlier AssetCompress versions and they’re awesome. I’m excited to use the new one!

Awesome, as always.

Nate Ritter on 2/12/11

Thanks Mark

saleh souzanchi on 2/14/11

Hello, Mark. I’m new to CakePHP and have come across your blog a few times in my “how would I do this?” google searches. I’ve used asset packagers with RoR, Cold Fusion, and .NET, and was really hoping to find something comparable for PHP. MD5 file names are a huge plus for me (far-futures headers, automatic client-cache busting), and I was having a hard time finding any solutions offering this feature. I stumbled across your asset packager on Git Hub and it’s incredible; very well structured, cleanly coded, full-featured, and even documented. Just wanted to drop you a line to say thanks, I appreciate all the work you’ve done, and look forward to future releases!

Take care,
Jon

Jon Aldinger on 3/11/11

Hi Mark, I believe this is the best cake asset compressor out there. The ability to create build “groups” makes asset_compress the first I’ve seen that even addresses the “balance” you speak of in your original release post.

The only thing I couldn’t figure out was why _generateAsset() didn’t return a path to the file in $this->_iniFile[$iniKey][‘cacheFilePath’] without returning the url passing through PHP. It was a very easy modification to this method to get the helper to make better use of _generateAsset()‘s file_exists(WWW_ROOT . $base) so that I ended up with a direct relative web path to the build file itself rather than getting JsFilesController->get() caught up in the mix. I always felt like passing assets through php should be avoided if possible and since you already had the file_exists() in there it seemed like an obvious choice. I think the only problem is that you need to manually delete the build if you aren’t using hashed build names.

Secondly, I had the weirdest instance of a jquery plugin that your strip comments filter completely erased. It was the jQuery Form plugin (I believe 2.43). I was going to email you about it but upon updating to the latest version of the plugin it no longer deletes the entire contents. One look at your regular expression and I let things be ;)

Also, for anyone interested, https://github.com/kbjr/UglifyJS.php watching this and wondering if you know of any others working on a php port.

Aaron on 4/15/11

Jon: Welcome :) Glad you found it useful.

Aaron: The controller method should only be called if there is no cached build file around. The only PHP called in that case should be to generate the URL, which isn’t overly expensive. I’m glad to hear the plugin is no longer eating your whole file :)

mark story on 4/20/11

Hi Mark, any plans for cakephp 2.0, or does the existing plugin support it already?

Mike on 12/1/11

Comments are not open at this time.