Grails 3 fontawesome设置 [英] Grails 3 fontawesome setup
问题描述
我试图在我的grails 3项目中加入fontawesome(fa)。我看到grails2上有一个插件,但是如何安装这个插件的配置和解释在grails 3中似乎不起作用。
所以我尝试了通过创建资产/字体/目录并将字体放在那里手动添加fa,将css添加到我的样式表目录并从application.css中引用它。当我通过grails run-app运行Idea时,所有fa资源都显示正常。 然而,当我打包一个war文件在tomcat中运行时,根本没有一个fa资源显示出来。当我查看为应用程序创建的编译样式表时,我放入我的fa样式表的../fonts/已被删除,然后找不到字体文件。
@ font-face {font-family:'FontAwesome'; src:url('fontawesome-webfont-32400f4e08932a94d8bfd2422702c446.eot? v = 4.5.0')
生成的字体资源和其他所有字体资源不可解析(404 )从我的应用程序的根目录,但是如果我将/ assets /添加到它们,则可以解析。
我在资产管道中错过了配置的明智之处,以使其正常工作?
在grails-app / assets中创建一个名为'fonts'的文件夹。在这个文件夹中放置包含font-awesome文件的解压缩内容。你应该有这样的东西:
grails-app
| __assets
| __fonts
| __css
| __fonts
| __less
| __scss
....
然后,资产管道知道新的目录,在build.gradle文件中引用它。你应该有这样的东西:
资产{
minifyJs = true
minifyCss = true
includes = [fonts / *]
}
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?
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/*"]
}
这篇关于Grails 3 fontawesome设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!