如何做LESS @import没有@import字面上?

编程入门 行业动态 更新时间:2024-10-28 13:14:05
本文介绍了如何做LESS @import没有@import字面上?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我使用LESS。从Google PageSpeed我知道,在CSS文件中使用 @import 会妨碍网站速度。所以我想从我的CSS中排除任何 @import 的东西。我有2种不同的样式表 reset.css 和 rebuild.css - 避免 @import 我将他们的所有代码复制到我的主样式表。所以我的网站的真正的样式下面有许多代码,这是一个问题。所以我需要两个样式表到 styles.less (主样式表)文件,在某种程度上, @import 所以,当我用 WinLESS 将它们编译成纯 styles.css 时,它们实际上不会生成任何@import。我想把它们插入到style.css中,当我将 styles.less 编译成 styles.css 。

I'm using LESS. From Google PageSpeed I've learnt that, using @import in CSS file will hamper the site speed. So I'd like to exclude any @import thing from my CSS. I have 2 different stylesheets reset.css, and rebuild.css - to avoid @import I copied all of their code into my main stylesheet. So the real styles of my site got below many code and that's a problem. So I need the two stylesheets to @import into the styles.less (main stylesheet) file, in a way, so that, they actually won't generate any @import when I'm compiling them with WinLESS into pure styles.css. I want them to insert physically into the style.css when I'll compile the styles.less into styles.css.

我想要 styles.less like:

@import('reset.css'); @import('rebuild.css'); /* SITE STYLES HERE */

c $ c> styles.css 为:

But want the rendered styles.css to be:

code from reset.css code from rebuild.css /* THEN, SITE STYLES HERE */

我使用 WinLESS 从LESS编译CSS文件,而不是直接使用 .less ,而是使用 styles.css

I'm using WinLESS to compile the CSS file from LESS, and NOT USING .less with JavaScript directly, but using the styles.css only.

推荐答案

最简单的方法:

@import (less) 'reset.css'; @import (less) 'rebuild.css'; /* SITE STYLES HERE */

更多推荐

如何做LESS @import没有@import字面上?

本文发布于:2023-11-23 11:03:18,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1621218.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:字面   如何做   import

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!