SCSS 编译后将 @import 保留在 CSS 的末尾 [英] Keep @import at the end of CSS after SCSS compile

查看:78
本文介绍了SCSS 编译后将 @import 保留在 CSS 的末尾的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们需要将 @import 放在我的 CSS 文件的末尾.例如:

We need to put @import at the end of my CSS file. For example:

SCSS:

@import "reset.css";
Body {
   font: 0.8em arial;
}
@import "customation.css"

编译为:

@import "reset.css";body{font: 0.8em arial;}@import "customation.css"

但编译后它改变了@import顺序,CSS文件将是这样的:

but after compile it changed the @import order and CSS file will be this:

@import "reset.css";@import "customation.css";body{font: 0.8em arial;}

@importing 文件放在custom.css 文件末尾对我们进行自定义非常重要.我们不能手动将 @import 放到 CSS 文件中,因为 SCSS 文件将被更改并且 CSS 文件将被重写.有什么建议吗?

It's very important for us to keep @importing the custom.css file at the end for our customization. We can't put the @import to CSS file manually because SCSS file will be changed and CSS file will be rewritten. Any suggestion?

推荐答案

您是否出于任何特定原因使用 @import?有性能影响,并且不再有主要用例.

Are you using @import for any particular reason? There are performance impacts, and no major use case anymore.

如果你使用 Sass 的 @import 来连接文件会更好,这也允许你按照你想要的顺序导入并依赖级联.

It would be better if you used Sass's @import to concatenate the file instead, this would also allow you to import in the order you want and rely on the cascade.

@import "reset";

Body {
  font: 0.8em arial;
}

@import "customation";

这篇关于SCSS 编译后将 @import 保留在 CSS 的末尾的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆