如何将特定文件添加到资产? [英] How to add specific files to assetic?
问题描述
我的包有我的自定义资源目录,其中有一些文件:
I have my custom resources directory for my bundle where there are some files:
/longpathtoSymfony/src/MyOwn/Bundle/MyOwnBundle/Resources/public
|-- bootstrap
| |-- css
| | |-- bootstrap-theme.css
| | |-- bootstrap-theme.min.css
| | |-- bootstrap.css
| | |-- bootstrap.min.css
| | `-- carousel.css
| |-- fonts
| | |-- glyphicons-halflings-regular.eot
| | |-- glyphicons-halflings-regular.svg
| | |-- glyphicons-halflings-regular.ttf
| | `-- glyphicons-halflings-regular.woff
| `-- js
| |-- bootstrap.js
| |-- bootstrap.min.js
| |-- holder.js
| `-- respond.min.js
|-- css
| `-- custom.css
|-- fonts
| |-- glyphicons-halflings-regular.svg
| |-- glyphicons-halflings-regular.ttf
| `-- glyphicons-halflings-regular.woff
|-- images
|-- img
`-- js
|-- html5shiv.js
|-- jquery-1.10.2.min.map
|-- jquery.js
`-- less-1.3.3.min.js
并且所有 js 和 css 文件都正确地放入公共文件夹,因此我可以访问 bootstrap/css/xxx.css
文件等等,除了 字体文件.
And all js and css files are correctly put to public folder, thus i can access to bootstrap/css/xxx.css
files and so on, except font files.
我不知道我应该怎么做才能将它们复制到 web
目录.如果我尝试 php app/console assetic:dump
然后只复制 css 和 js 文件:
I dont know what I should do to get them copied to the web
directory. If I try php app/console assetic:dump
then only the css and js files are copied:
php app/console assetic:dump
Dumping all dev assets.
Debug mode is on.
18:41:17 [file+] /longpathToSymfony/app/../web/css/bef717e.css
18:41:17 [file+] /longpathToSymfony/app/../web/css/bef717e_bootstrap.min_1.css
18:41:17 [file+] /longpathToSymfony/app/../web/js/6f9045a.js
18:41:17 [file+] /longpathToSymfony/app/../web/js/6f9045a_html5shiv_1.js
18:41:17 [file+] /longpathToSymfony/app/../web/js/6f9045a_respond.min_2.js
18:41:17 [file+] /longpathToSymfony/app/../web/css/0c1e28e.css
18:41:17 [file+] /longpathToSymfony/app/../web/css/0c1e28e_carousel_1.css
18:41:17 [file+] /longpathToSymfony/app/../web/js/0aa0509.js
18:41:17 [file+] /longpathToSymfony/app/../web/js/0aa0509_jquery_1.js
18:41:17 [file+] /longpathToSymfony/app/../web/js/0aa0509_bootstrap.min_2.js
18:41:17 [file+] /longpathToSymfony/app/../web/js/0aa0509_holder_3.js
18:41:17 [file+] /longpathToSymfony/app/../web/js/0aa0509_less-1.3.3.min_4.js
我应该怎么做才能包含字体文件?我在动态下载 jquery-1.10.2.min.map
时遇到了同样的问题.有什么办法可以对symfony说嘿把它放在web资源文件夹中,因为我的一些组件需要它"?
What should I do to include font files too? I'm having the same problem with jquery-1.10.2.min.map
, which is downloaded dynamically.
Is there any way to say to symfony "hey put it in the web resource folder, because some of my components need it"?
推荐答案
我遇到了同样的问题,我只是尝试使用以下作为解决方法.到目前为止似乎有效.
I had the same problem and I just tried using the following as a workaround. Seems to work so far.
{% stylesheets
output='assets/fonts/glyphicons-halflings-regular.ttf'
'bundles/bootstrap/fonts/glyphicons-halflings-regular.ttf'
%}{% endstylesheets %}
注意任何输出的省略,这意味着模板上没有显示任何内容.当我运行 assetic:dump
时,文件被复制到所需的位置,并且 css 按预期包含工作.
Notice the omission of any output which means nothing shows up on the template. When I run assetic:dump
the files are copied over to the desired location and the css includes work as expected.
这篇关于如何将特定文件添加到资产?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!