我的应用程序需要URL中的一些资源。我正在导入它们:
{% block stylesheets %}
{% stylesheets
'http://cdnjs.cloudflare.com/ajax/libs/foundicons/3.0.0/foundation-icons.css'
'bundles/bmatznerfoundation/css/foundation.min.css'
'bundles/arpanetkorepeteshop/css/*'
filter="cssrewrite"
%}
<link rel="stylesheet" type="text/css" href="{{ asset_url }}" />
{% endstylesheets %}
{% endblock %}
如果我转储资产
php app/console assetic:dump
下载源代码。但是如果源中有一些导入,则不会下载它。
@font-face {
font-family: "foundation-icons";
src: url("http://cdnjs.cloudflare.com/ajax/libs/foundicons/3.0.0/foundation-icons.eot");
}
有没有办法全部下载?
答案 0 :(得分:1)
短版:没有。解析用于导入的CSS文件(在这种情况下是外部字体文件)远远超出了像Assetic这样的范围。如果你愿意在代码中挖掘并编写自己的代码,有很多方法可以挂钩Assetic,但在这种情况下,我建议你自己下载字体图标包 - 你毕竟是捆绑它你自己是一个项目依赖。
答案 1 :(得分:0)
No, the CSS is parsed at page load time, so the browser will do the downloading, not assetic. But here's a suggestion:
Instead of adding the URLs to all of your stylesheets block, you could also define them as assets in your config (YML in my case), and then just include the assets you need in your stylesheets block.
# Assetic Configuration
...
...
assets:
foundation_icons:
inputs:
- //cdnjs.cloudflare.com/ajax/libs/foundicons/3.0.0/foundation-icons.css
output: css/foundation_icons.css
jquery:
inputs:
- %kernel.root_dir%/../vendor/jquery/jquery/jquery-2.1.3.js
- //ajax.googleapis.com/ajax/libs/jqueryui/1.11.1/jquery-ui.min.js
output: js/jquery.js
datatables:
inputs:
- //cdn.datatables.net/1.10.7/js/jquery.dataTables.min.js
output: js/datatables.js
Then in your stylesheets block, just call
{% stylesheets
'@foundation_icons'
'bundles/bmatznerfoundation/css/foundation.min.css'
'bundles/arpanetkorepeteshop/css/*'
%}
you can now load @foundation_icons in any view, and dont need to be copying any URLs.