Assetic Bundle 配置 - 说明

AsseticBundle Configuration - Explaination

config.yml.

中关于 AsseticBundle Config 的文档中没有真正的细节
assetic:
    debug:                "%kernel.debug%"
    use_controller:
        enabled:              "%kernel.debug%"
        profiler:             false
    read_from:            "%kernel.root_dir%/../web"
    write_to:             "%assetic.read_from%"
    java:                 /usr/bin/java
    node:                 /usr/bin/node
    ruby:                 /usr/bin/ruby
    sass:                 /usr/bin/sass
    # An key-value pair of any number of named elements
    variables:
        some_name:                 []
    bundles:

        # Defaults (all currently registered bundles):
        - FrameworkBundle
        - SecurityBundle
        - TwigBundle
        - MonologBundle
        - SwiftmailerBundle
        - DoctrineBundle
        - AsseticBundle
        - ...
    assets:
        # An array of named assets (e.g. some_asset, some_other_asset)
        some_asset:
            inputs:               []
            filters:              []
            options:
                # A key-value array of options and values
                some_option_name: []
    filters:

        # An array of named filters (e.g. some_filter, some_other_filter)
        some_filter:                 []
    workers:
        # see https://github.com/symfony/AsseticBundle/pull/119
        # Cache can also be busted via the framework.templating.assets_version
        # setting - see the "framework" configuration section
        cache_busting:
            enabled:              false
    twig:
        functions:
            # An array of named functions (e.g. some_function, some_other_function)
            some_function:                 []

我对

特别感兴趣
 read_from:    don't understand the path, too
    write_to:    

因为我不太懂怎么用

所以,我想使用 SCSS 和 Compass,我在 AppBundle/Resources/assets/styles/main.scss 中有一个文件夹

我必须在 config.yml 中设置什么,那个资产知道他如何找到 main.scss 作为全局设置?

除非您尝试更新 Assetic reads/writes 所在的目录(因此默认为 /web),否则您无需在此处进行任何更改。该配置可以从Symfony documentation上的一个很好的部分理解。您将在以下位置找到您需要的内容:

read_from:            "%kernel.root_dir%/../web"
write_to:             "%assetic.read_from%"

这些 路径 到 writable/readable 的目录,并暴露给 public。在这种情况下,这意味着它会为阅读和写作寻找 /path/to/app/../web

一般来说,检查 php app/console config:dump-reference X 以找到给定包的默认配置,其中 X 是包配置名称。在你的情况下,试试后者:php app/console config:dump-reference assetic

现在,就我所见,您想要的是从您的角度使用 compass/sass。 在你的树枝文件中,输入以下内容:

{% stylesheets 'path/to/main.scss' filter='compass' %}
    <link rel="stylesheet" type="text/css" href="{{ asset_url }}">
{% endstylesheets %}

添加指南针的配置后,如果需要调整,你应该已经准备好了。

有帮助吗?不是,能否请您提供更多详细信息?