Hi all
Just a quick update. I've accomplished something similar to idea (2) by exposing some existing compiler functionality via a command line flag. In particular, the JobDescriptionBuilder has a setCssRenamingPrefix method which simply appends a prefix to all renamed CSS classes. For each CSS file I generate, I would just use a different prefix to guarantee I get no CSS class conflicts when loading multiple CSS files that have been compiled separately.
Quick question: Is there any reason why such flag does not currently exist?
Here's a small patch if you are interested:
--- a/src/com/google/common/css/compiler/commandline/ClosureCommandLineCompiler.java
+++ b/src/com/google/common/css/compiler/commandline/ClosureCommandLineCompiler.java
@@ -172,6 +172,10 @@ public class ClosureCommandLineCompiler extends DefaultCommandLineCompiler {
"com.google.common.css.compiler.gssfunctions."
+ "DefaultGssFunctionMapProvider";
+ @Option(name = "--css-renaming-prefix",
+ usage = "A prefix for all the renamed CSS classes.")
+ private String cssRenamingPrefix = "";
+
/**
* All remaining arguments are considered input CSS files.
*/
@@ -202,6 +206,7 @@ public class ClosureCommandLineCompiler extends DefaultCommandLineCompiler {
builder.setEliminateDeadStyles(true);
builder.setCssSubstitutionMapProvider(renamingType
.getCssSubstitutionMapProvider());
+ builder.setCssRenamingPrefix(cssRenamingPrefix);
GssFunctionMapProvider gssFunctionMapProvider =
getGssFunctionMapProviderForName(gssFunctionMapProviderClassName);