我有2个文件,一个是.css(在vendor / somevendor / somelibrary / css /中),另一个是.scss(在@ ProjectMainBundle / Resources / public / css /)里面。
我想将.scss编译成带有Sass过滤器的.css,然后使用Yui过滤器缩小两个.css文件。我尝试了不同的变体:
{% stylesheets
'%kernel.root_dir%/../vendor/somevendor/somelibrary/css/somelibrary.css'
'@ProjectMainBundle/Resources/public/css/*'
filter='compass,yui_css' %}
<link rel="stylesheet" type="text/css" media="screen" href="{{ asset_url }}" />
{% endstylesheets %}
问题是Sass过滤器也被应用于.css文件,这会引发缩进错误。
在我的config.yml中,我添加了相应的'apply_to'参数,但没有帮助:
# Assetic Configuration
assetic:
debug: %kernel.debug%
use_controller: false
bundles: [ProjectMainBundle]
#java: /usr/bin/java
filters:
cssrewrite: ~
#closure:
# jar: %kernel.root_dir%/Resources/java/compiler.jar
sass:
bin: /usr/local/bin/sass
apply_to: "\.scss$"
compass:
bin: /usr/local/bin/compass
apply_to: "\.scss$"
yui_css:
jar: %kernel.root_dir%/../vendor/yahoo/yui-compressor/build/yuicompressor-2.4.7.jar
apply_to: "\.css$"
yui_js:
jar: %kernel.root_dir%/../vendor/yahoo/yui-compressor/build/yuicompressor-2.4.7.jar
apply_to: "\.js$"
那我该怎么做?我不希望得到超过1个.css。
答案 0 :(得分:3)
找到它:https://github.com/kriswallsmith/assetic/issues/101
删除'filter = compass,yui_css'部分。