0

i'm attempting to include fontawesome (fa) in my grails 3 project. I saw for grails2 there was a plugin for this, but the configuration and explanation for how to install this plugin didn't seem to work in grails 3.

So I tried to add fa more or less manually by creating an assets/fonts/ directory, and placing the fonts in there, added the css to my stylesheets directory and referenced it from the application.css. When I run in Idea via grails run-app all the fa resources show up fine.

However when I package a war file to run in tomcat, none of the fa resources show up at all. When I look at the compiled style sheet that is created for the app, the ../fonts/ that I put in my fa style sheet has been removed, and then the font files can't be found.

@font-face {font-family: 'FontAwesome';src: url('fontawesome-webfont-32400f4e08932a94d8bfd2422702c446.eot?v=4.5.0')

This generated font resource, and all the others are not resolvable(404) from the root of my application, but are resolvable if I prepend /assets/ to them.

What am I missing configuration wise with the asset pipeline to get this working?

WizardsOfWor
  • 2,974
  • 29
  • 23
  • 1
    did you check bootstrap-framework plugin for grails3? seems fa is included there – user3718614 Mar 28 '16 at 20:13
  • thanks for pointing me in that direction. – WizardsOfWor Mar 28 '16 at 23:36
  • FYI the bootstrap plugins for grails 3 are all out of date/unmaintained. strangely, bootstrap (and old version) seems to be included by default in grails 3.3.0 (not sure if it was in there before this). However, including fontawesome is a manual, non trivial process sadly. – John Little Jul 10 '17 at 17:06

3 Answers3

1

As mentioned in the comments you can use the Grails 3 bootstrap-framework hosted on GitHub https://github.com/kensiprell/bootstrap-framework

Works like a charm.

feuernurmitm
  • 312
  • 2
  • 11
1

Create a folder called 'fonts' in grails-app/assets. In this folder place the unzipped content containing font-awesome files. You should have something like:

grails-app
|__assets
   |__fonts
      |__css
      |__fonts
      |__less
      |__scss
   ....

Then, for the asset pipeline to know the new directory, reference it in the build.gradle file. You should have something like:

assets {
    minifyJs = true
    minifyCss = true
    includes = ["fonts/*"]
}
mtazamaji
  • 160
  • 1
  • 6
  • I have followed your steps to put the fontawesome files under assets, and have edited the build.gradle. How do I now include the fonts in the app? how do I link to them so I can use them? – John Little Jul 10 '17 at 17:29
0

Download Fonts from this link enter link description here and in that add Fonts folder only to assets in grail app.Add below code:

assets {
minifyJs = true
minifyCss = true
includes = ["fonts/*"]

}

Mounika R
  • 1
  • 1
  • 2