wymeditor/wymeditor — pull request #381 by micolous (2013-01-13 13:16:18+00:00)
Title: Add support for compiling with Google's Closure Compiler; make Makefile depend on output files rather than target; fix issue with UglifyJS compilation where it would continue even if minification failed; add make clean target

This pull request addresses three things:

1. It adds support for using Google's [Closure Compiler](https://developers.google.com/closure/compiler/), instead of UglifyJS.

It is slower than UglifyJS, but generates smaller code and doesn't require Node.js.

I compared the size of the output of UglifyJS from the official tarball, with using Closure with only a fix for Issue #380 (which makes the source file 2 bytes **larger**):

* Source size: 355,925 bytes
* UglifyJS (from official tarball): 137,370 bytes (38.6% of original)
* Closure (from #380): 134,074 bytes (37.7% of original)

This represents a size saving of 3,296 bytes in the minified code. On high-traffic sites, this small saving is multiplied.

In addition, Closure Compiler has it's own `lint` that catches additional potential issues in the code (for example, it caught Issue #380).

I have run the unit tests with Chrome and Firefox and they appear to still pass.

2. It changes the Makefile to use dependancies based on files, rather than targets. This means that it is possible to easily use different minification tools in the same Makefile interchangably, without significant code duplication.

3. It fixes an issue where the Makefile may attempt to continue to run, even if UglifyJS is missing or failed for some reason when using file-based dependancies rather than targets.

Piping output from UglifyJS rather than using it's `-o` option means that a file is always created (with no content), even if the build fails.

This way if the build fails, `make` will immediately abort and subsequent re-runs will not try to package no output.

4. Adds a `make clean` target for deleting the `dist` directory.