简体   繁体   English

如何通过sass或指南针合并css文件(不是.scss文件)

[英]How to merge css files (not .scss files) by sass or compass

Although I know CSS file is a valid SCSS but there is some reason ,so I can't change some files subfix to SCSS 虽然我知道CSS文件是有效的SCSS,但是由于某些原因,所以我无法将某些文件子修补程序更改为SCSS

global_min.scss global_min.scss

@import url("global/reset.css")
@import url("global/frameset.css");
@import url("global/header.css");
....
....

Can sass or compass merge it (´・_・`) 可以sass或指南针合并它('·_·`)

您可以尝试使用Chris Eppstein自己的Sass CSS导入器插件 :)

http://sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html#import http://sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html#import

@import takes a filename to import. @import需要导入文件名。 By default, it looks for a Sass file to import directly, but there are a few circumstances under which it will compile to a CSS @import rule: 默认情况下,它会查找要直接导入的Sass文件,但在某些情况下,它会编译为CSS @import规则:

  • If the file's extension is .css. 如果文件的扩展名是.css。
  • If the filename begins with http://. 如果文件名以http://开头。
  • If the filename is a url(). 如果文件名是url()。
  • If the @import has any media queries. 如果@import有任何媒体查询。

If none of the above conditions are met and the extension is .scss or .sass, then the named Sass or SCSS file will be imported. 如果不满足上述任何条件且扩展名为.scss或.sass,则将导入指定的Sass或SCSS文件。

You can't do that with SASS without renaming the CSS files. 如果不重命名CSS文件,则无法使用SASS进行操作。

I suggest that you use some kind of CSS compressor to concatenate and minify your CSS code. 我建议您使用某种CSS压缩器来串联和缩小CSS代码。 Please have a look at Yeoman , currently the most solid approach to handling this kind of tasks. 请查看Yeoman ,它是目前处理此类任务的最可靠方法。

如果要将所有css文件合并到单个已编译的css文件中,则需要将其扩展名更改为sass或scss,并使更改与该格式兼容。

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

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