如何在sass中@import .css文件作为.scss文件? [英] How to @import .css file as a .scss file in sass?
问题描述
我正在使用gulp作为任务运行程序,为我合并并缩小 scss
文件。在这种情况下,如果我尝试导入常规的 CSS
文件,它将被编译为css import
语句,如下所示:
I am using gulp as a task runner which merge and minifying scss
files for me. In this case if I try to import a regular CSS
file, it will compile to a css import
statement as below:
/* style.scss */
@import "../../bower_components/animate.css/animate.css";
/* style.css */
@import url(../../bower_components/animate.css/animate.css);
因此,如何导入该常规css文件,以具有已编译版本其中的 style.css
而不是 css @import
语句?
So how to import that regular css file, to have a compiled version of that in the style.css
instead of just css @import
statement?
推荐答案
只需执行以下操作:
/* style.scss */
@import "../../bower_components/animate.css/animate";
只要不写文件扩展名,导入不带扩展名的文件,编译器就会把文件放进去内容放在 style.css
中,而不是放置 @import
规则。
Just don't write file extension, Import the file without the extension, the compiler will put the file content in style.css
instead of putting @import
rule.
这篇关于如何在sass中@import .css文件作为.scss文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!