简体   繁体   English

如何将@import .css文件作为sass中的.scss文件?

[英]How to @import .css file as a .scss file in sass?

I am using gulp as a task runner which merge and minifying scss files for me. 我正在使用gulp作为任务scss器,为我合并和缩小scss文件。 In this case if I try to import a regular CSS file, it will compile to a css import statement as below: 在这种情况下,如果我尝试导入常规CSS文件,它将编译为css import语句,如下所示:

/* style.scss */
@import "../../bower_components/animate.css/animate.css";

/* style.css */
@import url(../../bower_components/animate.css/animate.css);

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? 那么如何导入那个普通的css文件,在style.css有一个编译后的版本,而不仅仅是css @import语句?

Simply do this: 只需这样做:

/* style.scss */
@import "../../bower_components/animate.css/animate";

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. 只是不写文件扩展名,导入没有扩展名的文件,编译器会将文件内容放在style.css而不是放入@import规则。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM