Skip to content

Loading…

Less resources in plugins are not processed #36

Open
pparson opened this Issue · 5 comments

4 participants

@pparson

I am facing the problem that less resources within plugins are not processed (i.e. not converted to css and not bundled) when run from a project.
It works fine when running the plugin standalone. Also css and less files within the project are processed as expected.

I have reproduced such a constellation with the least amount of code and uploaded the plugin and project here:
http://www.2shared.com/complete/4OM-RVC6/lesstest.html

If there is any patch or workaround for cases like this, I'd be very happy. Or am I abusing grails-lesscss-resources plugin?

Thanks and best regards,
Peter

@pparson

I did some debugging and found out that lesscssResourceMapper is called with the less resource name in question (the one from the plugin). Having a breakpoint in getOriginalFileSystemFile(String) revealed that the file is not in the list of resources, the call to grailsApplication.parentContext.getResource(sourcePath).file throws an exception.
I used the evaluator to call grailsApplication.parentContext.getResources("**/*") and in the list are no resources from the plugin, only the project resources.

@pparson

Me again... sorry for providing additional infos step by step, but I am not an expert with Grails plugins and have to dig inside.

I dived a bit deeper into the lesscss-plugin code now and would like to ask one thing: is there a special reason that getOriginalFileSystemFile must be called at all? As far as I can see, the content would be exactly the same as in originalFile and input is only used to compile from, nothing else.

So I tried editing line 24 to simply say
File input = originalFile;
instead of
File input = getOriginalFileSystemFile(resource.sourceUrl);
and everything seems to work fine - at least for my use case.

I'll keep it like this for now as a temporary workaround, however I'd be happy if there was a clean solution, i.e. which does not involve me messing about in the plugin code (and maybe creating side effects by doing so)

@k2s
k2s commented

This missing functionality makes the plugin unusable. Per my understanding of resource plugin system, this should work, but it doesn't:

resource url:[plugin: 'MyPlugin', file: 'css/local.less'], attrs: [rel: "stylesheet/less", type: 'css'], bundle: 'bundle_MyApp'

@vviskari

It works if you define your resources in the plugin like this:

modules = {
    myModuleInPlugin {
        resource url: [dir:'/less', file:'some-styles.less', plugin: 'my-plugin'], attrs:[rel: "stylesheet/less", type:'css']
    }
}

See the plugin definition inside the url and use dash notation instead of camelCase.

@jklingen

We had the same problem as described by @pparson, and it worked fine for us after changing the resources notation as suggested by @vviskari above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.