许多SCSS / SASS文件到一个CSS文件? [英] Many SCSS/SASS files to one CSS file?

查看:88
本文介绍了许多SCSS / SASS文件到一个CSS文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能使sass侦听一个有许多sass文件的目录并生成一个CSS文件?我已经找到一种方法通过包括许多sass文件到一个(style.scss):

Is it possible to make sass listen to a directory with many sass files and generate one CSS file? I have found a way by including many sass files into one (style.scss):

@import "scss/header";
@import "scss/footer";

然后运行以下代码:

sass --watch style.scss:style.css

但是问题是我必须在生成新的CSS文件之前更改该文件。

but the problem is that I have to change that file before I generate a new CSS file.

推荐答案

sass将能够注意到@imported文件的更改,并更新相关文件。

If you watch the directory, sass will be able to notice changes in @imported files, and update dependent files.

style.scss:

style.scss:

@import "header";
@import "footer";

并执行:

sass --watch .

它将目录中的所有文件编译为.css;忽略名称以 _ 开头的文件。

It will compile all files in the directory to .css; ignoring files whose name start with a _.

我修改_header.scss或_footer.scss,如果更新style.scss。

I you modify _header.scss or _footer.scss, if will update style.scss too.

您也可以在其他目录中输出:

You can also output in an other directory:

sass --watch .:output_dir/

这篇关于许多SCSS / SASS文件到一个CSS文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆