Grails 3 fontawesome setup

青春壹個敷衍的年華 提交于 2019-12-13 04:28:31

问题


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?


回答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.




回答2:


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/*"]
}



回答3:


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/*"]

}



来源:https://stackoverflow.com/questions/36267396/grails-3-fontawesome-setup

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!