【问题标题】:Assetic, twitter bootstrap and lessAssetic、Twitter 引导程序和更少
【发布时间】:2012-05-27 18:12:44
【问题描述】:

配置:

assetic:
    debug:          %kernel.debug%
    use_controller: false
    read_from:      %kernel.root_dir%/../public
    filters:
        less:
            node: /usr/bin/node
            node_paths: [/usr/local/lib/node_modules]

树枝模板:

{% block stylesheets %}
{% stylesheets filter='less'
    '@MyBundle/Resources/public/bootstrap/less/bootstrap.less'
%}
    <link rel="stylesheet" href="{{ asset_url }}" />
{% endstylesheets %}
{% endblock %}

这几乎可以正常工作。

我有一个问题,没有图像,它们被引用相对 url("../img/glyphicons-halflings.png") 但它们不存在。

还有一个问题,这适用于 node.js,但是如果我在生产服务器上没有 node.js,我只上传编译好的 css 会起作用吗?

【问题讨论】:

    标签: node.js symfony twitter-bootstrap assets


    【解决方案1】:

    我认为你也应该使用 cssrewrite 过滤器,像这样:

    {% block stylesheets %}
    {% stylesheets filter='less,cssrewrite'
        '/bundles/mybundle/bootstrap/less/bootstrap.less'
    %}
        <link rel="stylesheet" href="{{ asset_url }}" />
    {% endstylesheets %}
    {% endblock %}
    

    不要忘记使用此命令发布您的资产:

    app/console assets:install --symlink web
    

    为了回答你的最后一个问题,是的,上传编译后的 css 就可以了。

    【讨论】:

    • 谢谢!是否有任何文档可以让我看到如何配置此过滤器?
    • 我不记得我在哪里找到它...只需将 cssrewrite: ~ 放入您的 config.yml 即可启用它。
    • 现在它用 url("../Resources/public/bootstrap/img/glyphicons-halflings.png") 引用它,这是朝着好的方向迈出的一步,但仍然是 404。谢谢。
    • 是的,它可以工作,谢谢,但只有当我将 twitter 引导程序复制到 /public/bundles/... 时,我想将它存储在我的包中。这可能吗?
    • 哇,不知道那个选项,谢谢!实际上,不管有没有 --symlink 选项,它都可以工作,转储它们很重要。
    猜你喜欢
    • 1970-01-01
    • 2014-11-12
    • 1970-01-01
    • 1970-01-01
    • 2013-06-04
    • 1970-01-01
    • 2012-06-12
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多