Grails 3 - 添加字体资源文件夹

标签 grails fonts resources

我找不到可以告诉 grails 包含带有一些字体( Font Awesome )的字体文件夹的地方。在过去的版本中,它会包含在 config.groovy 文件中,但它似乎在版本 3 中没有。我在哪里可以放置这个配置来告诉 grails 在生成我的 View 时计算这个文件夹?

谢谢

最佳答案

我假设您习惯于使用资源插件,而不是 Grails 3 默认使用的 Assets 管道。从升级指南:

Step 7 - Migrate Static Assets not handled by Asset Pipeline If you have static assets in your web-app directory of your Grails 2.x application such as HTML files, TLDs etc. these need to be moved. For public assets such as static HTML pages and so on these should go in src/main/resources/public.

TLD descriptors and non public assets should go in src/main/resources/WEB-INF.

As noted earlier, src/main/webapp folder can also be used for this purpose but it is not recommended.



这意味着您需要通过默认安装在 Grails 3 中的 Assets 管道插件传递静态资源。 asset pipeline 是什么?

The Grails Asset-Pipeline is a plugin used for managing and processing static assets in Grails applications. Asset-Pipeline functions include processing and minification of both CSS and JavaScript files. It is also capable of being extended to compile custom static assets, such as CoffeeScript or LESS.



在您的项目中的以下位置创建一个文件夹:
grails-app/assets/fonts

阅读有关 linking to assets 和插件的文档。

Plugins Plugins also can have the same "grails-app/assets" folder and their URL mapping is also the same. This means it can be more important to ensure unique naming / path mapping between plugins. This is also powerful in the sense that a plugin can add helper manifests to be used within your apps like jquery, bootstrap, font-awesome, and more.

These plugins also differ in the fact that the assets within their web-app directory also become available under a similar structure



如果您遵循这些说明,您应该能够在您的 GSP 页面中使用字体很棒的资源。您将需要花一点时间学习 Assets 管道。还有另一种选择,您也可以使用 font awesome plugin

关于Grails 3 - 添加字体资源文件夹,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31974177/

相关文章:

jsp - Grails - 使用自定义 JSP 标签库

grails - 简单的 Grails 应用程序超出了 Heroku 内存配额

grails - 在Grails中保存关联的域类

html - 将字体文件中的所有小写字母设为大写

css - 当一个 CSS 属性可以有多个值时,这些值是否总是用空格分隔?

scala - Scala 脚本的有用资源

grails - 如何卸载GVM

python - 来自 QFontDatabase 的令人困惑的行为

java - 澄清资源包中写入的数据 - Java

android - 高效使用 Android 资源