disable obfuscation in gwt css resources

Option 1 setting in gwt.xml

use the

<set-configuration-property name="CssResource.style" value="pretty"/>

the code that generates the aforementioned  very  long class names is present in the
computeObfuscatedNames  method of com.google.gwt.resources.rg.CssResourceGenerator  class:

 if (prettyOutput) {
          obfuscatedClassName += "-"
              + type.getQualifiedSourceName().replaceAll("[.$]", "-") + "-"
              + name;

Retaining the original class names is a very useful tool while development. (obfuscation is ideal for only production)
Unfortunately, you can not override the above method which means we are stuck with these long names. I wish there was a way to have GWT just retain the class names as they are.

Option 2 use @external

con: using @external for each and every class is cumbersome and cant be used for styles within widgets
pro: we can keep the original name.

By checking out the source-code, and cross comparing with the GWT wiki, I found:

/* @external also accepts tail-globs */
@external .myProject-*;
.myProject-text {}
.myProject-foo {}

So, if you want to let all the classes in a CSS resources in a file be external, use:

@external *;

Another flavor is

@external .legacySelectorA, .legacySelectorB;
.legacySelectorA { .... }
.legacySelectorB { .... }

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s