我读过很多关于此的文章,但无法让它适用于我的项目。
所以基本上我有一个 Symfony2 项目,其中包括 twitter bootstrap (v3)。在开发模式下一切正常,但当我在产品模式下尝试时,我收到错误消息,说找不到 twitter 引导字体:
Failed to load resource: the server responded with a status of 404 (Not Found) http://localhost:8080/Symfony/css/fonts/glyphicons-halflings-regular.woff
Failed to load resource: the server responded with a status of 404 (Not Found) http://localhost:8080/Symfony/css/fonts/glyphicons-halflings-regular.ttf
Failed to load resource: the server responded with a status of 404 (Not Found) http://localhost:8080/Symfony/css/fonts/glyphicons-halflings-regular.svg#glyphicons_halflingsregular
这是正常的,因为我在 Symfony/ 中没有 css/ 文件夹
该项目的结构如下:
app/
src/
vendor/
web/
css/
compiled/
fonts/
js/
树枝文件:
{% block stylesheets %}
{% stylesheets output="css/compiled/main.css" filter='cssrewrite'
'css/bootstrap.min.css'
'css/general.css'
'css/navigation.css'
%}
<link rel="stylesheet" href="{{ asset_url }}" />
{% endstylesheets %}
{% endblock %}
I used:
php app/console assetic:dump --env=prod
我已经检查了 bootstrap.min.css (在 web/css/compiled 中)文件(prod 和 dev),它们都有相同的字体路径。类似于(../../../fonts/fontName.ext)。
如果我们查看该路径,它在开发模式和生产模式下都不应该工作,因为该路径将 fonts/ 文件放在 Web 目录之外。然而,它可以在开发模式下运行。
关于如何解决这个问题有什么想法吗?
我会很感激。