【发布时间】:2016-02-15 03:28:34
【问题描述】:
我想从一个 sass 文件中输出多个 css 文件。 我有一个文件:schemes.scss,代码如下:
$schemes: (
'light': (
'body-background': white,
'headline-color' : #111,
'subheadline-color': #222
),
'dark': (
'body-background': black,
'headline-color' : #ddd,
'subheadline-color' : #eee
),
'moderate': (
'body-background': gray,
'headline-color' : black,
'subheadline-color' : #333
)
);
@each $scheme in $schemes{
//do something to export to separate file
@include scheme-base-mixin($scheme);
}
所以结果是 3 个单独的 css 文件:
scheme-light.css:
body{
background-color: white;
}
h1{
color: #111;
}
.subheadline{
color: #222;
}
scheme-dark.css:
body{
background-color: black
}
h1{
color: #ddd;
}
.subheadline{
color: #eee;
}
scheme-moderate.css:
body{
background-color: gray
}
h1{
color: black;
}
.subheadline{
color: #333;
}
纯SASS可以做到这一点吗? ..或者用 gulp (真的不喜欢)。
在我的情况下,提取 sass 的常见部分并创建 3 个不同的 sass 文件不是解决方案。我有 9 个方案乘以几十个复杂的组件。通过类包装器附加方案也不是解决方案。
【问题讨论】:
-
我也很想知道这个。我目前正在以一种非常低效的方式生成附属样式表,使用颜色变量并为每个附属包含不同的颜色文件。
标签: css web architecture sass web-frontend