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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/42732832/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 12:28:19  来源:igfitidea点击:

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

csssass

提问by bobsilon

I am using gulp as a task runner which merge and minifying scssfiles for me. In this case if I try to import a regular CSSfile, it will compile to a css importstatement as below:

我使用 gulp 作为任务运行器,它scss为我合并和缩小文件。在这种情况下,如果我尝试导入常规CSS文件,它将编译import为如下css语句:

/* 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 compiledversion of that in the style.cssinstead of just css @importstatement?

那么如何导入该常规 css 文件,以在而不是仅语句中获得该文件的编译版本?style.csscss @import

回答by bobsilon

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.cssinstead of putting @importrule.

只是不要写文件扩展名,导入没有扩展名的文件,编译器会将文件内容放入style.css而不是放入@import规则。