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

Closed
nvinet opened this Issue May 10, 2012 · 8 comments

Comments

Projects
None yet
5 participants
@nvinet

nvinet commented May 10, 2012

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

This comment has been minimized.

Show comment Hide comment
@nvinet

nvinet May 10, 2012

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 commented May 10, 2012

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

This comment has been minimized.

Show comment Hide comment
@nvinet

nvinet May 10, 2012

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 commented May 10, 2012

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

This comment has been minimized.

Show comment Hide comment
@nvinet

nvinet May 10, 2012

Works like a charm with lesscss-resource version 1.0.1

nvinet commented May 10, 2012

Works like a charm with lesscss-resource version 1.0.1

@superflav

This comment has been minimized.

Show comment Hide comment
@superflav

superflav May 25, 2012

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

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

This comment has been minimized.

Show comment Hide comment
@paulfairless

paulfairless Jun 5, 2012

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)

Owner

paulfairless commented Jun 5, 2012

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

This comment has been minimized.

Show comment Hide comment
@superflav

superflav Jun 5, 2012

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

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

This comment has been minimized.

Show comment Hide comment
@tixxit

tixxit Jun 19, 2012

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.

tixxit commented Jun 19, 2012

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 Nov 2, 2012

Closed

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

@lhanson

This comment has been minimized.

Show comment Hide comment
@lhanson

lhanson Jan 30, 2013

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

lhanson commented Jan 30, 2013

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

@joergrech joergrech referenced this issue in joergrech/KickstartWithBootstrap Sep 11, 2013

Closed

Upgrade Bootstrap to 3.0? #46

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