我编译SCSS文件,它似乎删除我的意见。什么命令我可以用它来保持所有的评论?
>SASS input.scss output.css
我看到两种类型的注释在我SCSS。
// Comment
和
/* Comment */
有什么区别?
两种类型的评论之间的差异是很容易的:
// Some comment for a single line
和
/* This is
a multiline comment
for large descriptions */
据the officials docs of SASS,你只能使用多行注释选项将其保存为编译输出文件。
萨斯一样,SCSS支持在CSS的输出和评论是不保留双方的意见。然而,SCSS的评论是显著更灵活。它支持标准的多CSS注释以/ * * /,这是在输出保存在可能的情况。这些评论可以有任何格式化你喜欢的;萨斯将尽最大努力把它很好地格式化。
SCSS也使用//对于被扔掉,像萨斯评论。与萨斯,虽然在// SCSS注释可能出现在任何地方,只持续到该行的末尾。
所以下面的CSS:
/* This comment
should be kept
and not be thrown away */
.class {
margin: 0 auto;
}
// This comment will be thrown away
.extra-class {
color: blue;
}
将汇编成:
/* This comment
should be kept
and not be thrown away */
.class {
margin: 0 auto;
}
.extra-class {
color: blue;
}
要解决你的编译问题,您需要将//
到/* */
注释转换。
正如@Roy上面说的,多行注释(/ * * /)保持在导致CSS,但它取决于格式使用的是预先处理你的SASS。
如果您使用的紧凑型模式,或其他任何“CSS minifier”,你应该更好地利用
/*! important comment */
这些意见被保存在你的CSS的紧凑型(精缩)的版本。
例:
html {
/*! important comment */
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
结果(紧凑型,精缩版):
html{/*! important comment */-webkit-box-sizing:border-box;box-sizing:border-box}