Closed nvinet closed 11 years ago
Oh .. I'm using all those nice resource plugins together (might create side effects): runtime ":resources:1.1.6" runtime ":cache-headers:1.1.5" runtime ":cached-resources:1.0" runtime ":yui-minify-resources:0.1.5" compile ":lesscss-resources:1.3.0"
Hi,
I just did a test on a plain Grails 2.0 project with only these 2 plugin: runtime ":resources:1.1.6" compile ":lesscss-resources:1.3.0"
Here is my applicationResource.groovy: modules = { application { resource url:'js/application.js' }
test {
resource url:'css/main.css'
resource url:'css/mobile.css'
resource url:'css/test.less', attrs:[type:"css"], bundle: 'bundle_test'
}
}
When I run the app the bundle url returns 404 as the '/static/ part is now missing: link href="/bundle-bundle_test_head.css" type="text/css" rel="stylesheet" media="screen, projection"
If I remove the bundle, the less file is not integrated to the bundle but the paths are good:
link href="/static/bundle-bundle_test_head.css" type="text/css" rel="stylesheet" media="screen, projection" link href="/static/css/test_less.css" type="text/css" media="screen, projection" rel="stylesheet"
Works like a charm with lesscss-resource version 1.0.1
Not sure how this will work because, according to the latest Grails Resources Plugin guide:
NOTE If a resource declares "attrs" or "wrapper" it will not be bundled at all. This is because bundling does not make sense in this situation unless all the attrs and wrapper logic match.
Unfortunately there are some limitations I try to work around in the resources plugin which may be causing this issue.
I have noticed that for bundling to work, ensure you have at least 1 .css file declared after your .less file in the bundle (even if it is just a dummy file). If this resolves your issue I will update the docs.
In the latest version it is actually possible to remove the attrs and bundle from the declaration ( although this is still a work in progress)
Removing the attributes from the less line and reordering the files so at least one CSS comes after the less files did the trick. Here's what I have now, and it's bundling both into /myapp/static/bundle-bundle_core_head.css:
core {
resource url: 'less/blah.less'
resource url: "css/reset.css"
}
I can confirm that adding a dummy.css file to the list of resources (I kept attrs in resource definition for less files) fixed the problem for me.
I can also confirm that a dummy CSS file with :lesscss-resources:1.3.1
and no attrs specified will finally allow me to bundle resources as I would expect. Since I struggled to get this working, here's an example of my setup in case it's helpful to others:
modules = {
bootstrap {
defaultBundle 'core'
resource url: 'bootstrap/less/bootstrap.less'
}
core {
defaultBundle 'core'
dependsOn 'bootstrap'
resource url: 'less/main.less'
resource url: 'css/dummy.css'
}
}
Hi,
I've started a new project with the latest grails goodnesses and after some fiddling with the less resource plugin (including the Mapper issue that is still not deployed and the bundle issue that I raised earlier) all seems to work fine but the compiled CSS files aren't bundled. If I use pure CSS files only the bundling works like a charm. I'm not sure if it is a side effect of the fact that the less resource plugin hasn't been compile to Grails 2.0
Cheers