gpt4 book ai didi

less - 可以使用lessc压缩LESS文件而不删除注释吗?

转载 作者:行者123 更新时间:2023-12-04 16:34:34 25 4
gpt4 key购买 nike

我正在执行以下行来压缩较少的文件:

lessc -x site.less site.css

还有我所有的 CSS 块评论 /*foo */被删除。

可以压缩我的 less 文件并保留评论吗?

更新 : 目前 SimpLESS从 1.4 版开始,更改日志说:

if a LESS file starts with a CSS block comment, SimpLESS will keep that comment after minification (i.e. for Wordpress)



我想知道是否可以用 lessc 来做命令。

最佳答案

如果你想在编译的 LESS 文件中保留注释,你应该对非压缩代码使用块注释:

网站.css

/* this is a keeper */
.foo {
...
}

对于缩小代码,您应该使用 --yui-compress/*!开始评论:

站点.min.css
/*! this is a keeper */
.foo{...}

这是因为 lessc命令与 --yui-compress flag 通过 YUI Compressor 管理 CSS,和 YUI Compressor allows comments when they begin with /*! .

关于less - 可以使用lessc压缩LESS文件而不删除注释吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18369307/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com