Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

adding support to compile less files inside a plugin #7

wants to merge 3 commits into


None yet
8 participants

jvalde commented Sep 16, 2011

Hi Paul,

Thanks for your contribution this plugin made our work possible,

we are working using a plugin oriented architecture where we have a core plugin which provides common resources as templates, css, javascripts and images, the plugin works great when using it on the main application (the less files live on the main app) however it fails when the less files live in a plugin, because it can't work out the right path,

I have added support for this case, when you got a plugin that uses lesscss-resources that then is then installed on another application,

There is something dodgy that I don't like on code that I committed and it's the way that I used to find out whether the resource lives on a plugin I had to rely on the sourcePath, as far as I've seen the object ResourceMeta does not provide a pluginName property (the name of the plugin passed in the resource for instance "resource url:[dir:'css', file:'basic.less', plugin:'basic-core'], bundle:'bundle_style'") which would be ideal for this case,

Please check the changes and let me know your thoughts,

jvalde commented Sep 16, 2011

I have added support to inline pluglins. This is when the less files to be compiled live on an inline plugin

I've also run into this issue. Some brief testing last week seemed to indicate that the above code still works, but doesn't work for a binary plugin.

jvalde commented Apr 16, 2012

hi Ben,

I've made some extra changes that might have fixed the problem you're having, however I have not pushed them to github yet, I will do it tomorrow as I'm not currently at my office.

longwa commented Apr 23, 2012

I assume this change would fix a problem we are having trying to use the bootstrap plugin. Namely, we want to install the plugin for the majority of the bootstrap files and then just override the few that need customizing in our application. Also, we need to import some of the mixins for use in our own custom LESS. Right now, the plugin doesn't seem to be able to resolve things inside the plugin when doing an import.

eplarson commented May 5, 2012

+1 vote for integrating this - I'm having the same issue. less files are compiled when I run my plugin standalone, but as soon as use my plugin in another application, I get nothing.

Interestingly, the exact same issue affects the other less resources plugin (http://grails.org/plugin/less-resources)

+1, need a fix for this. The other less-resources plugin has it's own issues, so right now I can't use either.

jvalde commented May 15, 2012

Hi all,

There was an issue for the version 0.6 of this plugin, where it was unable to find less files when they lived inside a plugin, this version attempts to fix this problem however as far as I've tested the newest version of this plugin solves the issue mentioned above.

Another issue I was having which isn't fixed on this version nor on the newest version of this plugin is the inability of importing mixins from other plugins inside less files. In our case we have a core plugin which holds base js, less, shell|templates (gsp), then we have other plugins or apps which make use of those base files. A cool feature that we needed in order to get the most flavor out of less was the ability to import seamlessly mixins in less files from the core plugin. So if some of you are facing the same situation let me know and I will commit a version which solves this case with some examples,

Hope this helps

Which plugin does it work right now? yours? or Paul Fairless's plugin? Can you commit your fix to solve these issues? I was struggling with this problem with this and less-resources plugin for a few days and I don't know what else to do...
Thanks a lot!

Martín Caballero

jvalde commented May 15, 2012

both this version and the newest one (Paul Fairless's) solve the problem of having the less files living inside a plugin however neither of them allow you to import mixins from a plugin to either an app or another plugin.

I explain a little bit further the case that is not supported,

for example you have plugin A which contains a less file to be imported:


.bordered {
  border-top: dotted 1px black;
  border-bottom: solid 2px black;

Then you have another plugin b which contains

@import "_toBeImported";

#menu a {
  color: #111;
.post a {
  color: red;

I have a version that solves both cases but it still in progress however we are using it on a production site and works like a charm, will commit it this week, you may find it useful

Thanks for the response!
I look forward for your submit...

longwa commented May 15, 2012

+1 for the import fix, itwould be much appreciated. I spent a bit of time looking at the fix but now I've decided to wait for you :)

It stinks that both less plugins have issues that prevent them doing what we need right now. Namely, I just want to use bootstrap as a plugin and import mixins, etc. to use in my application stylesheets.

Here's how to replicate the problem I'm seeing. Do the following (in grails 2.0.1, at least):

  1. grails create-plugin lesstestplugin
  2. Add a Resources artifact that looks like this:
    modules = {

        mystyle {
            resource url:'less/test.less',attrs:[rel: "stylesheet/less", type:'css']
            resource url:'less/test2.less',attrs:[rel: "stylesheet/less", type:'css']

  1. Create the two files mentioned in the 'mystyle' module
  2. Create an index.gsp file under views and import the module:

    <r:require module="mystyle" />

    <r:layoutResources />

    <r:layoutResources />
  1. Note that the two files are compiled to css and imported correctly:
<link href="/lesstestplugin/static/less/test_less.css" type="text/css" media="screen, projection" rel="stylesheet" />
<link href="/lesstestplugin/static/less/test2_less.css" type="text/css" media="screen, projection" rel="stylesheet" />
  1. Now create a new app: grails create-app lesstest
  2. Import your plugin in to the app
// in BuildConfig.groovy, above dependency resolution closure:
grails.plugin.location.'lesstestplugin' = "../lesstestplugin"
  1. In the app's main.gsp, import the module previously defined in lesstestplugin :
<r:require module="mystyle"/>
  1. Note that the two files are imported, but NOT compiled to css. Result:
<link href="/lesstest/static/less/test.less" type="text/css" media="screen, projection" rel="stylesheet/less" />
<link href="/lesstest/static/less/test2.less" type="text/css" media="screen, projection" rel="stylesheet/less" />

Is there anything wrong with this example? I don't think I can break it down to be much simpler. I've tried many other avenues, and the bottom line is that I can't get less files to compile if they're in a plugin, period.

I tested version of this plugin and could not get LESS resources within a binary plugin to be compiled, I tested defining the resource both within the plugin and within the web-app which uses the plugin. If I changed the plugin definition in BuildConfig.groovy to be inline (which AFAIK is the same as a source plugin) then the resources could be compiled.

jvalde, I don't see a recent commit from you, but you mentioned above that you had some code which might fix this issue?

cweekly commented Sep 7, 2012

+1 @jvalde or anyone else who can help, please fix the ability to import .less files from plugins!
I'm using grails 2.0.0 + twitter-bootstrap plugin v2.1.1 + lesscss-resources plugin v1.3.0.3.

I need to selectively override small parts of twitter-bootstrap (e.g. parts of variables.less), but @import just doesn't work in my custom .less files, the twitter-bootstrap resources (provided by the plugin) just can't be found.
So far, blocked on ability to make these plugins work together for what seems like a vanilla / standard use case.

Thanks very much in advance for any help!

selera commented Nov 2, 2012

I would like to hear from anyone who has news about getting less resources accessible to a grails app from a binary plugin.

@jvalde - do you have anything to share?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment