Twitter bootstrap Symfony-Bootstrap glyphicons-assetic dump将url(css)重写到错误的路径(将';./';添加到路径,这是不应该发生的)

Twitter bootstrap Symfony-Bootstrap glyphicons-assetic dump将url(css)重写到错误的路径(将';./';添加到路径,这是不应该发生的),twitter-bootstrap,symfony,assetic,Twitter Bootstrap,Symfony,Assetic,我的目标是在我的Symfony(2.8)web应用程序中使用引导字形图标字体。我正在使用assetic,但我的问题就在那里。我在composer.json文件中添加了引导(“twitter/bootstrap”:“3.3”)。运行composer安装后,我检查了原始bootstrap.css文件(供应商文件夹)中的路径,字体的url如下所示(当然可以,因为可以在那里找到字体):“src:url('../font/glyphions-halflings-regular.eot');” 但是,在运行

我的目标是在我的Symfony(2.8)web应用程序中使用引导字形图标字体。我正在使用assetic,但我的问题就在那里。我在composer.json文件中添加了引导(“twitter/bootstrap”:“3.3”)。运行composer安装后,我检查了原始bootstrap.css文件(供应商文件夹)中的路径,字体的url如下所示(当然可以,因为可以在那里找到字体):“src:url('../font/glyphions-halflings-regular.eot');”

但是,在运行assetic:dump后检查web/css文件夹中的结果时,我看到路径被错误地更改为“src:url('。/。/font/glyphicons halflings regular.eot');”(注意添加的“。/”)

my config.yml文件中的资产部分如下所示:

assetic:
debug:          "%kernel.debug%"
use_controller: false
bundles:        [ 'AppBundle' ]
filters:
    cssrewrite: ~
assets:
    bootstrap_js_and_jquery:
        inputs:
            - '%kernel.root_dir%/../vendor/components/jquery/jquery.js'
            - '%kernel.root_dir%/../vendor/twbs/bootstrap/dist/js/bootstrap.js'
    bootstrap_css:
        inputs:
            - '%kernel.root_dir%/../vendor/twbs/bootstrap/dist/css/bootstrap.css'
    bootstrap_glyphicons_ttf:
        inputs:
            - '%kernel.root_dir%/../vendor/twbs/bootstrap/dist/fonts/glyphicons-halflings-regular.ttf'
        output: "fonts/glyphicons-halflings-regular.ttf"
    bootstrap_glyphicons_eot:
        inputs:
            - '%kernel.root_dir%/../vendor/twbs/bootstrap/fonts/glyphicons-halflings-regular.eot'
        output: "fonts/glyphicons-halflings-regular.eot"
    bootstrap_glyphicons_svg:
        inputs:
            - '%kernel.root_dir%/../vendor/twbs/bootstrap/fonts/glyphicons-halflings-regular.svg'
        output: "fonts/glyphicons-halflings-regular.svg"
    bootstrap_glyphicons_woff:
        inputs:
            - '%kernel.root_dir%/../vendor/twbs/bootstrap/fonts/glyphicons-halflings-regular.woff'
        output: "fonts/glyphicons-halflings-regular.woff"
    bootstrap_glyphicons_woff2:
        inputs:
            - '%kernel.root_dir%/../vendor/twbs/bootstrap/fonts/glyphicons-halflings-regular.woff2'
        output: "fonts/glyphicons-halflings-regular.woff2"
这样做的结果是css文件可以在“web/css”中找到,字体可以在“web/fonts”中找到(因此所有这些看起来都很好)

在我的小树枝模板中,我应用了CSSREWITE规则:

{% stylesheets '@bootstrap_css' filter='cssrewrite'%}
        <link rel="stylesheet" href="{{ asset_url }}" />
{% endstylesheets %}
{%stylesheets'@bootstrap\u css'filter='cssrerewrite'%}
{%endstylesheets%}
谁能解释一下为什么css文件中的路径会被重写,在路径前面加上“./”,这会导致找不到字体(404)?有没有人能在类似的环境下工作


提前谢谢

请注意,关闭“cssrewrite”过滤器确实解决了我的问题。。。但这是为什么呢?为什么在这个特定场景中使用“cssrerewrite”作为过滤器时,assetic:dump会在路径前面添加“./”?因为这就是过滤器的用途。请参阅@glerendegui“这将解析CSS文件并更正内部路径以反映新位置”。关于“新位置”:引导CSS文件可以在web/CSS中找到,而引导字体可以在web/fonts中找到。因此,“新位置”不需要将“./”添加到引导css文件中字体的路径中。我认为assetic足够“聪明”,知道它不应该在这个特殊情况下重写路径,但显然不是这样。因此,在这种特殊情况下,我不再应用cssrewrite筛选器。cssrewrite筛选器一次处理一个资产。正如您所说,在处理@bootstrap\u css时,分析这些字体规则的输出是不够聪明的。CSSRewite似乎只是为捆绑资产设计的。我建议在使用post-install cmd创建链接后看看这个解决方案easier@glerendegui谢谢事实上,该解决方案也适合我(同时我继续跳过引导的“CSSRETRITE”过滤器)。请注意,关闭“CSSRETRITE”过滤器确实解决了我的问题。。。但这是为什么呢?为什么在这个特定场景中使用“cssrerewrite”作为过滤器时,assetic:dump会在路径前面添加“./”?因为这就是过滤器的用途。请参阅@glerendegui“这将解析CSS文件并更正内部路径以反映新位置”。关于“新位置”:引导CSS文件可以在web/CSS中找到,而引导字体可以在web/fonts中找到。因此,“新位置”不需要将“./”添加到引导css文件中字体的路径中。我认为assetic足够“聪明”,知道它不应该在这个特殊情况下重写路径,但显然不是这样。因此,在这种特殊情况下,我不再应用cssrewrite筛选器。cssrewrite筛选器一次处理一个资产。正如您所说,在处理@bootstrap\u css时,分析这些字体规则的输出是不够聪明的。CSSRewite似乎只是为捆绑资产设计的。我建议在使用post-install cmd创建链接后看看这个解决方案easier@glerendegui谢谢事实上,这个解决方案也适合我(与此同时,我继续跳过引导的“cssrerewrite”过滤器)。