如何通过命令行将目录 SASS/SCSS 转换为 CSS? [英] How to convert directory SASS/SCSS to CSS via command line?
问题描述
我试过了:
sass-convert --from scss --to css --recursive app/assets/stylesheets temp
但这只会将 css 转换为 SASS,而我想要相反的方式.
But this only converts css to SASS, and I want the other way around.
然后我看了一下sass命令,但是好像不能传目录.
Then I looked at the sass command, but it doesn't look like I can pass it a directory.
推荐答案
要进行一次性 Sass 编译而不是 watch
,您可以从命令行执行此操作:
To do a one-time Sass compile instead of a watch
, you can do this from the command line:
sass --update scss:css
要让 Sass 导入一个文件(通常是部分文件,文件名以 _
开头),您可以在 Sass 文件中执行此操作:
To have Sass import one file (usually a partial, with a _
starting the filename), you can do this inside a Sass file:
@import "_base.scss";
这样,Sass 就知道在哪里你希望包含发生.
This way, Sass knows where you want the include to occur.
默认情况下,Sass 不能导入整个目录.但是,Sass Globbing gem 可以.您可以从命令行安装它:
By default, Sass can't import an entire directory. The Sass Globbing gem, however, can. You can install it from the command line:
gem install sass-globbing
然后用它观看:
sass -r sass-globbing --watch sass_dir:css_dir
请注意,globbing 将按字母顺序导入文件,因此如果发生这种情况,请确保您的 CSS 会适当地级联.
Note that globbing will import files alphabetically, so be sure your CSS will cascade appropriately if this occurs.
这篇关于如何通过命令行将目录 SASS/SCSS 转换为 CSS?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!