Kiwi
Kiwi

Reputation: 1093

How to group JS and CSS using Grails asset-pipeline plugin?

I'm currently using the Grails resources plugin and I have many modules defined like this one:

bootstrap {
    resource url:'js/libs/bootstrap/bootstrap.min.js'
    resource url:'css/libs/bootstrap/bootstrap-responsive.css'
    resource url:'css/libs/bootstrap/bootstrap-glyphicons.css'
    resource url:'css/libs/bootstrap/bootstrap.min.css'
}

This is very convenient because it groups the Javascript and CSS files together into a single conceptual Bootstrap module.

I'm looking into the asset-pipeline plugin now, and it appears that files can only require other files of the same type, which means that I now have two trees of dependencies (CSS & JS) rather than one, which is a problem because there are interdependencies, e.g., bootstrap.js depends on bootstrap.css.

Does the asset-pipeline plugin allow for declaring inter-type dependencies? If not, what is the best way to deal with this issue?

Upvotes: 11

Views: 1256

Answers (1)

biniam
biniam

Reputation: 8199

I don't consider this as a problem. Organizing JS and CSS files separately (even though both belong to the same package/product such as Bootstrap) is a good thing and if the JS is not able to refer to the CSS, change the URI.

In my opinion, if you want to use Bootstrap with Grails, try twitter-boostrap.

Checkout my blog post regading Bootstrap CSS templating in Grails and if you want an example, checkout an project I did using Twitter Bootstrap here.

Upvotes: 0

Related Questions