I’m wanting to pull in Twitter’s Bootstrap into my Grails 3 app. What’s the best way to do this? I neither want to place the source under version control nor reference remote CDNs.
Adding "org.grails:grails-bootstrap:3.0.1"
as a compilation dependency in my build.gradle
pulls down the associated JAR, but how do I plumb this into my application to ultimately be able to reference Bootstrap classes from my views/GSPs?
4
Answers
You should be using this plugin and the documentation tells you exactly what to do.
Javascript grails-app/assets/javascripts/application.js:
Stylesheet grails-app/assets/javascripts/application.css:
I don’t think there is any usable Bootstrap plugin for Grails 3 yet. I think it is easier to include WebJars Bootstrap in your project and then reference the files in your gsp’s or layouts.
I don’t have a workable example ready, but take a look at this code snippet:
https://github.com/canoo/open-dolphin-lazybones-templates/commit/d1a2c3bc4d0852a331f66287314b6348d6e76e14
Webjars worked for me, I’ve used the webjars link in my
application.js
and in myapplication.css
, but the links are not always well defined (see typeahead example)application.js:
application.css:
I’m using this plugin kensiprell/bootstrap-framework and added following path into
.gitignore
so that resources are downloaded upon first run.