我想将资产添加到使用它的每个捆绑包中。
这是我当前的 config.yml 配置:
assets:
bootstrap_css:
inputs:
#Original File
- %kernel.root_dir%/Resources/less/billing.bootstrap.less
- %kernel.root_dir%/../vendor/braincrafted/bootstrap-bundle/Braincrafted/Bundle/BootstrapBundle/Resources/less/form.less
- %kernel.root_dir%/../vendor/components/font-awesome/less/font-awesome.less
- %kernel.root_dir%/../src/HomeBundle/Resources/css/main.css
filters:
- lessphp
output: css/bootstrap.css
bootstrap_js:
inputs:
- %kernel.root_dir%/../vendor/twbs/bootstrap/js/transition.js
- %kernel.root_dir%/../vendor/twbs/bootstrap/js/alert.js
- %kernel.root_dir%/../vendor/twbs/bootstrap/js/button.js
- %kernel.root_dir%/../vendor/twbs/bootstrap/js/carousel.js
- %kernel.root_dir%/../vendor/twbs/bootstrap/js/collapse.js
- %kernel.root_dir%/../vendor/twbs/bootstrap/js/dropdown.js
- %kernel.root_dir%/../vendor/twbs/bootstrap/js/modal.js
- %kernel.root_dir%/../vendor/twbs/bootstrap/js/tooltip.js
- %kernel.root_dir%/../vendor/twbs/bootstrap/js/popover.js
- %kernel.root_dir%/../vendor/twbs/bootstrap/js/scrollspy.js
- %kernel.root_dir%/../vendor/twbs/bootstrap/js/tab.js
- %kernel.root_dir%/../vendor/twbs/bootstrap/js/affix.js
- %kernel.root_dir%/../src/HomeBundle/Resources/js/bootbox.js
- %kernel.root_dir%/../vendor/braincrafted/bootstrap-bundle/Braincrafted/Bundle/BootstrapBundle/Resources/js/bc-bootstrap-collection.js
output: js/bootstrap.js
jquery:
inputs:
- %kernel.root_dir%/../vendor/components/jquery/jquery.js
output: js/jquery.js
DataTables_css:
inputs:
- %kernel.root_dir%/../src/HomeBundle/Resources/css/DataTables/jquery.dataTables.css
filters:
- cssrewrite
output: css/dataTables.css
DataTables_js:
inputs:
- %kernel.root_dir%/../src/HomeBundle/Resources/js/DataTables/jquery.dataTables.min.js
- %kernel.root_dir%/../src/HomeBundle/Resources/js/DataTables/bootstrap.js
output: js/dataTables.js
#Xeditable
xeditable_js:
inputs:
- %kernel.root_dir%/../src/HomeBundle/Resources/js/xeditable/bootstrap-editable.min.js
output: js/xeditable.js
xeditable_css:
inputs:
- %kernel.root_dir%/../src/HomeBundle/Resources/css/xeditable/bootstrap-editable.css
output: css/xeditable.css
filters:
- cssrewrite
growl_js:
inputs:
- %kernel.root_dir%/../src/HomeBundle/Resources/js/growl/jquery.bootstrap-growl.min.js
output: js/growl.js
sortable_js:
inputs:
- %kernel.root_dir%/../src/HomeBundle/Resources/js/sortable/source/js/jquery-sortable-min.js
output: js/sortable.js
#java: /usr/bin/java
filters:
lessphp:
file: %kernel.root_dir%/../src/HomeBundle/Assets/Filter/lessc.php
apply_to: "\.less$"
# Formatter options: compressed, lessjs, classic
formatter: "compressed"
preserve_comments: false
cssrewrite: ~
#closure:
# jar: "%kernel.root_dir%/Resources/java/compiler.jar"
#yui_css:
# jar: "%kernel.root_dir%/Resources/java/yuicompressor-2.4.7.jar"
我正在从源代码编译 Bootstrap js 和 css 文件以减少请求的数量。某些 Bundles 将需要某些资产(Jquery 库)。但我不想告诉用户将这些文件添加到您的主配置中。我不觉得这是正确的。所以我正在寻找一种将它们添加到捆绑配置文件的方法。但到目前为止,我只能找到路由器或服务配置的操作指南和示例。但不适用于主配置文件中的数据。我试图将其添加为扩展,但无法弄清楚它是如何工作的。
我试过这个:
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('config.yml');
并将当前模块的内容添加到资产部分。但它没有用。那么我做错了什么?