本文介绍了使用assetic将scss和css文件组合成一个文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在一个 Symfony2 项目中,我有几个 cssscss 文件.我使用 compass 过滤器转储 scsscssrewrite 应用于所有:

In a Symfony2 project, I have several css and scss files. I use the compass filter to dump the scss ones and cssrewrite applied to all:

{% stylesheets
filter='compass, cssrewrite'
'scssFile1.scss'
'scssFile2.scss' %}
<link rel="stylesheet" href="{{ asset_url }}"/>
{% endstylesheets %}

{% stylesheets
filter='cssrewrite'
'cssFile1.css'
'cssFile2.css' %}
<link rel="stylesheet" href="{{ asset_url }}"/>
{% endstylesheets %}

我想将这些文件合二为一.我试过了:

I want to group those files into one. I've tried:

{% stylesheets
filter='compass, cssrewrite'
'scssFile1.scss'
'scssFile2.scss'
'cssFile1.css'
'cssFile2.css' %}
<link rel="stylesheet" href="{{ asset_url }}"/>
{% endstylesheets %}

但是我在执行 assetic:dump 时遇到错误,因为 css 文件没有 scss 扩展名.有什么办法可以将 scsscss 文件归为一个?

but I'm getting an error when doing assetic:dump because the css files have not the scss extension.Is there any way to group scss and css files into one?

推荐答案

如果你想合并不同扩展名的文件,你需要在 Assetic 过滤器配置中指定它,特别是 apply_to范围 .尝试像这个例子中那样修改,其中他们使用正则表达式(因此您可以使用它).例如,使用 .scss 和 .sass 扩展名:

If you want to combine files with different extensions, you´ll need to specify it in the Assetic filters configuration, specifically the apply_to parameter . Try modifying like in this example, in which they use regular expressions (so you can play around with it). For instance, to use .scss and .sass extensions:

assetic:
    filters:
        compass:
            apply_to:   "\.s[ac]ss$"

这篇关于使用assetic将scss和css文件组合成一个文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-16 16:46