Tyson,
This isn't really what you asked for, as it is not part of the
compiler itself. However, it provides some of the same functionality
when run as a step before the compiler in your build system.
I wrote a small utility (css_util.py) used in our build system to
generate a "CSS renaming map" for use with the closure-compiler. This
utility combines multiple CSS files together as well as "minifying"
CSS class names down to shorter variants. This can be combined with
goog.setCssNameMapping() and the closure-compiler to share your
"minified" class names across files (*.css, *.js, *.soy).
This utility is released under the APL v2 license and is located at:
https://samegoal.com/s/css_util.py.
The utility can be run as follows:
$ ./css_utils.py --css_file=input1.css --css_file=input2.css
--css_map_file=css_map.js --output_file=generated.css
The utility works as follows:
1) One or more input *.css files are supplied on the command line via
the --css_file flag. These files are concatenated together (in order).
2) A "renaming map" file is generated mapping long CSS class names to
their minified variants. This output file is specified using the
--css_map_file flag.
3) The CSS class names are rewritten and output into a new file using
the --output_file flag. This is the new CSS file that should be served
for your project.
In order to rename class names in your compiled javascript, it is
necessary to pass the css_map.js file to closurebuilder.py. One way to
do this is:
$ ./closurebuilder.py [other flags] -f --js=css_map.js
If you use soy templates, make sure the {{css [name]}} references are
substituted by running:
$ java -jar SoyToJsSrcCompiler.jar [other flags] --cssHandlingScheme goog
A quick warning that this utility was thrown together very quickly
before I had a good understanding of how the CSS renaming was done in
the compiler. Any improvements or suggestions are welcome. If I find
the time I will rewrite it to be faster and do more intelligent
renaming of the classes.
Thanks,
Andy