skip to Main Content

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


  1. You should be using this plugin and the documentation tells you exactly what to do.

    Javascript grails-app/assets/javascripts/application.js:

    //= require bootstrap
    

    Stylesheet grails-app/assets/javascripts/application.css:

    /*
    *= require bootstrap
    */
    
    Login or Signup to reply.
  2. 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

    Login or Signup to reply.
  3. Webjars worked for me, I’ve used the webjars link in my application.js and in my application.css, but the links are not always well defined (see typeahead example)

    application.js:

    //= require jquery-2.1.3.js
    //= require_tree .
    //= require_self
    //= require /webjars/bootstrap/3.3.5/js/bootstrap.min
    //= require /webjars/bootstrap-tagsinput/0.5/bootstrap-tagsinput
    //= require /webjars/typeaheadjs/0.11.1/typeahead.bundle.js
    

    application.css:

    /*
    *= require main
    *= require mobile
    *= require_self
    *= require /webjars/bootstrap/3.3.5/css/bootstrap-theme
    *= require /webjars/bootstrap/3.3.5/css/bootstrap
    *= require /webjars/bootstrap-tagsinput/0.5/bootstrap-tagsinput
    */
    
    Login or Signup to reply.
  4. I’m using this plugin kensiprell/bootstrap-framework and added following path into .gitignore so that resources are downloaded upon first run.

    /grails-app/assets/javascripts/bootstrap
    /grails-app/assets/javascripts/bootstrap-all.js
    /grails-app/assets/stylesheets/font-awesome
    /grails-app/assets/stylesheets/bootstrap
    /grails-app/assets/stylesheets/font-awesome-less.less
    /grails-app/assets/stylesheets/bootstrap-less.less
    /grails-app/assets/stylesheets/bootstrap-all.css
    /grails-app/assets/stylesheets/font-awesome-all.css
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search