Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Less resources in plugins are not processed #36

Open
pparson opened this issue Sep 19, 2012 · 5 comments
Open

Less resources in plugins are not processed #36

pparson opened this issue Sep 19, 2012 · 5 comments

Comments

@pparson
Copy link

pparson commented Sep 19, 2012

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
Copy link
Author

pparson commented Sep 19, 2012

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
Copy link
Author

pparson commented Sep 20, 2012

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
Copy link

k2s commented Jul 8, 2013

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
Copy link

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
Copy link

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants