11

Has anyone been able to integrate the wonderful shorthanded syntax of LESS with the awesomely module, re-factor friendly and type-safe CSS of GWT UiBinder?

<ui:style with="com.lesscss.gwt">
    .selector{
        /* Can I haz LESS in here? */
     }
</ui:style>

Naturally, you can use LESS with GWT -- You just have to use non-compiled css. I want my css to go through the LESS compiler, and then the GWT compiler.

4

2 回答 2

5

There are no direct libraries for that, no.

LESS doesn't even have a java compiler, so I really don't think it's ever going to happen.

Suppose you could write a pre-compile routine that will go through your ui.xml files, compile contents of ui:style nodes and put the compiled versions back. Then you will run into continuous problems with your IDE complaining about improper CSS code.

于 2012-04-30T18:27:15.463 回答
2

As said before, there was no libraries to do that directly. But there is now ;) !

I recently wrote and published a library (HexaCss for GWT) which allows to bind a GWT application to external CSS files, while keeping type-safety and optimizations like pruning and css name obfuscation.

You use it like the traditionnal CssResource (so typesafely), but instead of binding to a CSS file Inside your GWT project, it binds to any external CSS file that you want (you can even bind multiple CSS files to the same application which gives you themes for your GWT application).

So in your case, the external CSS file would have been generated with HexaCss. That's what I do on many projects.

You can even use Sass, GSS and so on. You can also use the already written bindings for Bootstrap and Skeleton.

A sample which resembles to your question is this one, where the CSS is generated with Less, and used in GWT with HexaCss, which is then usable from UiBinder or Java directly.

Link to the sample : http://lteconsulting.fr/hexacss/demo/sample3/index.html - This is a very ugly demo showing only the idea. You can switch between themes with the listbox on the top.

Hope this helps !

于 2015-04-20T14:20:00.920 回答