使用SASS和Symfony的最佳实践

问题描述 投票:1回答:0

我按照官方文档在我的Symfony 3.1项目中集成了SASS css。

现在在我的baseLayout.html.twig我有:

{% stylesheets filter="scssphp,cssrewrite" output="css/app.css"
    "assets/vendor/bootstrap-sass/assets/stylesheets/_bootstrap.scss"
    "assets/css/_variables.scss"
    "assets/css/layout.scss"
    %}
    <link rel="stylesheet" href="{{ asset_url }}"/>
{% endstylesheets %}

_variables.scss我有:

// Colors
$grey-super-light: #fafafa;

所以我想在layout.scss使用变量$grey-super-light

body {
  background-color: $grey-super-light;
}

但是当我运行php bin / console assetic:dump我收到此错误:

[Leafo\ScssPhp\Exception\CompilerException]
Undefined variable $blue-veruscript: line: 2

我知道一个解决方案是直接在layout.scss导入_variables.scss ,但我想知道是否有办法使用资产导入来共享不同文件之间的变量(以及其他SASS功能)。 通过这种方式,我可以避免在layout.scss中导入大量导入,并且我还可以导入完整目录而无需逐个文件列出。

知道这是否可行?

css sass symfony assetic
© www.soinside.com 2019 - 2024. All rights reserved.