Search code examples
grailsfont-awesome

How to integrate font-awesome 5.3 in grails 2.4.4 version without cdn link


I'm trying to integrate font-awesome 5.3 in grails 2.4.4 version, and I'm not supposed to use cdn link. Since grails 2.4.4 doesn't have dependency plugin support for font-awesome 5.3, I can not use the dependency plugins as well.

I just downloaded the bundle and tried to copy all files into my project folder and imported the all.css file into my main.gsp file, but that didn't work. Is there any other approach to fix this? [OR] Did I do anything wrong while placing the bundle files into my project? Can someone suggest me the best approach


Solution

  • Grails 2.4.4 already includes asset-pipeline plugin. So the process that I have adopted is the following:

    1. Create a directory that I usually call vendor in /grails-app/assets directory, here all css client dependencies should be located, as in your case font-awesome.

    2. In /grails-app/assets/stylesheets/application.css file include font-awesome as a dependency.

    Once this is done you will have access to the icons from the views that depend on application.css file.

    I attach an example

    Directory tree

    enter image description here

    /grails-app/assets/stylesheets/application.css

    /*
    *= require main
    *= require mobile
    *= require fontawesome-free-5.3.1-web/css/all.css
    *= require_self
    */
    

    In order to test, in this example I add an icon in the h1 tag in view /grails-app/views/index.gsp that extends from /grails-app/views/layouts/main.gsp and that in turn extends from application.css

    So in /grails-app/views/index.gsp I add the icon

    <h1>Application Status <i class="fab fa-font-awesome"></i></h1>
    

    Result

    enter image description here