3

当我尝试转储 Symphony2 应用程序的资产托管内容时,我收到以下错误:

$ php app/console assetic:dump -e prod
Dumping all prod assets.
Debug mode is off.

  [InvalidArgumentException]
  There is no "less" filter.

但是,据我所知,我不使用任何需要较少过滤器的资产,当然,我所有的树枝模板的 grep 都不会出现任何问题。

我通过 composer(Twitter 的引导程序)安装的依赖项之一有一些 .less 模板,但我没有在我的 twig 模板中引用它们,我只是将它指向 css 版本。Assetic 还会尝试甩掉它们吗?我怎么能告诉它不要呢?

作为参考,这是我在模板中包含 css 的方式

{% stylesheets filter="cssrewrite"
  '../vendor/jquery-ui-css/jquery-ui-css/*css'
  '../vendor/twitter/bootstrap/docs/assets/css/bootstrap*.css'
%}
<link rel="stylesheet" type="text/css" href="{{ asset_url }}">
{% endstylesheets %}
4

1 回答 1

8

hm many possible causes ...

1) some third-party bundle adds an assetic collection dependeing on the less filter in a compiler pass

2) there is an apply-to rule like

assetic:
    filters:
        less:
            apply_to: *.less

... in your assetic configuration i.e. app/config/config.yml

3) there is an asset collection using less filter in your configuration

assetic:
    assets:
        css_character:
            inputs: 
                 - "%kernel.root_dir%/../src/Acme/YourBundle/Resources/public/less/*.less"
             outputs:
                 - css/my.css
             filters:
                 - less

4) one of your third-party bundles provides a twig template using assetic's {% stylesheets %} function with the less filter:

{% stylesheets "@AcmeTwitterBundle/Resources/bootstrap/less/*.less" filter="less" %}
    {# ... {{ asset_url }} ...#}
{% endstylesheets %}

Now how to find out?

At first check your config files app/config/config.yml and other included ones for assetic entries using the less filter.

The easiest way to find out where the less filter is being used is installing ElaoWebProfilerExtraBundle, clearing your cache and having a look at the "Assetic" tab in the left-side menu of the profiler. You will get an overview of all assetic collections and the filters they use.

Another option - not involving a new bundle although WebProfilerExtraBundle is awesome - is to disable your third-party bundles one by one ( and clear the cache each time ) in app/AppKernel.php try if assetic:dump still throws the exception until you find the bad-boy.

Or dirty: enable the filter though less is probably not installed and see where the next exception is thrown:

assetic:
    filters:
        less: ~

... all in all i would bet you included the supercool mopa-bootstrap bundle of which almost nobody knows what it's actually doing behind the scenes but it's famous and many people install it because of it's KnpBundle's score.

meaning ... your exception would then be thrown because of the less files included in the templates provided by MopaBootstrapBundle i.e. here.

于 2013-07-11T23:22:12.703 回答