Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Compiled less files don't bundle in grails 2.0 #25

Closed
nvinet opened this Issue · 8 comments

5 participants

@nvinet

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

@nvinet

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"

@nvinet

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"

@nvinet

Works like a charm with lesscss-resource version 1.0.1

@superflav

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.

http://grails-plugins.github.com/grails-resources/guide/3.%20Declaring%20resources.html#3.4%20Bundling

@paulfairless
Owner

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)

@superflav

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"
}
@tixxit

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.

@zorrme zorrme referenced this issue in joergrech/KickstartWithBootstrap
Closed

White Gap between navbar and header when viewed on mobile. #18

@lhanson

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'
    }
}
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.