如何处理 scss 项目中的部分? [英] How to handle partials in an scss project?

查看:44
本文介绍了如何处理 scss 项目中的部分?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下问题:在我的服务器上,我在主目录中有一个 style.scss 文件 - 我使用了 sass --watch style.scss:style.css --style 压缩 等等.scss 被编辑了一个新的 style.css 将被创建.编辑子目录中的部分"后,我该怎么做才能创建新的 style.css?

Following problem: On my server I got a style.scss file in the main directory - I used sass --watch style.scss:style.css --style compressed and so everytime style.scss gets edited a new style.css will be created. What do I have to do that a new style.css will be created after editing a 'partial' in the sub directories?

文件夹结构:带有 style.scss 和 style.css 的 my_theme_main_directorymy_theme_main_directory/css/globals 中的部分

folder structure: my_theme_main_directory with style.scss and style.css partials in my_theme_main_directory/css/globals

我尝试过的:主目录中的命令:--watch css/globals:css/globals并且也在部分目录中:--watch _layout.scss:layout.css --style 压缩但没有创建新的 style.css

what I tried: command in main directory: --watch css/globals:css/globals and also in the partials directory: --watch _layout.scss:layout.css --style compressed but no new style.css was created

我删除了 style.css 并再次使用:sass --watch style.scss:style.css --style 压缩

I deleted style.css and used again: sass --watch style.scss:style.css --style compressed

最后更改在 style.css 中,但我想在编辑部分时自动生成 style.css.

Finally the changes were in the style.css but i want to get the style.css generated automatically when a partial gets edited.

推荐答案

执行此操作的标准方法是将 sass 文件与已编译的 css 文件分开.在您的 my_theme_main_folder 中创建文件夹 sass 并将所有 scss 文件移动到该文件夹​​中,包括部分文件(您可以根据需要构建它们).

Standard way to do this is to separate sass files form compiled css files. In your my_theme_main_folder create folder sass and move all the scss files to it, including partials (you can structure them as you like).

然后从my_theme_main_folder的层面运行:

sass --watch sass:css

它将监视整个 my_theme_main_folder/sass 文件夹,并在第一个文件夹中的任何更改时将所有内容编译到 my_theme_main_folder/css 文件夹.

It will watch the whole my_theme_main_folder/sass folder and compile everything to my_theme_main_folder/css folder on any change in the first folder.

这篇关于如何处理 scss 项目中的部分?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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