Grails developers, wait no more! I’ve just completed a first draft of an idea that I had this past summer after digging a little bit into the less.js implementation of Less, and this has finally taken the form of a Grails Less plug-in. The basic idea is to offer real-time compilation of Less files when developing your application, and statically compile your Less files as standard CSS when bundling your application for deployment (WAR).
By using this new plug-in, you can now use Less transparently in your Grails projects. You first create a .less file in your
web-app/css directory, then refer to it (without the file extension) in the HEAD section of your site using the available taglibs:
<less:stylesheet name="your_stylesheet" /> <less:stylesheet name="your_otherstylesheet" /> <less:scripts/>
You may add any number of Less files to your page this way.
When in development mode, .less files will be parsed automatically and directly in the browser. Your changes will be reflected after each page reload.When building your project (using the
war command), all your .less files will be compiled to standard CSS files, and the taglib will correctly refer to the static CSS files at runtime.
The plug-in should also play nicely with the ui-performance plug-in: as long as the ui-performance plug-in executes after lesscss, generated CSS files can be minified and bundled by the plug-in.
See the Github page for all the details on installing and using the plug-in.