Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sql-server-2005/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
带注释的SASS编译_Sass_Sass Rails - Fatal编程技术网

带注释的SASS编译

带注释的SASS编译,sass,sass-rails,Sass,Sass Rails,我正在编译一个SCSS文件,它似乎删除了我的评论。我可以使用什么命令来保存所有注释 >SASS input.scss output.css 我在SCS中看到两种类型的注释 // Comment 及 区别是什么?这两种评论之间的区别很简单: // Some comment for a single line 及 根据,只能使用多行注释选项将其保存到已编译的输出文件中 与Sass一样,SCSS支持CSS输出中保留的注释和不保留的注释。然而,SCS的评论要灵活得多它支持带有/**/的标准多

我正在编译一个SCSS文件,它似乎删除了我的评论。我可以使用什么命令来保存所有注释

>SASS input.scss output.css
我在SCS中看到两种类型的注释

// Comment


区别是什么?

这两种评论之间的区别很简单:

// Some comment for a single line

根据,只能使用多行注释选项将其保存到已编译的输出文件中

与Sass一样,SCSS支持CSS输出中保留的注释和不保留的注释。然而,SCS的评论要灵活得多它支持带有/**/的标准多行CSS注释,这些注释尽可能保留在输出中。这些注释可以有任何您喜欢的格式;Sass将尽最大努力使其格式良好

SCSS还将//用于被丢弃的注释,如Sass。但是,与Sass不同,//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中,但这取决于您在预处理SAS时使用的格式

如果您使用的是压缩模式,或任何其他“CSS迷你程序”,您最好使用

/*! important comment */
这些注释也保存在CSS的紧凑(缩小)版本中

例如:

html {
     /*! important comment */
     -webkit-box-sizing: border-box;
     box-sizing: border-box;
}
结果(精简版):

/*! important comment */
html {
     /*! important comment */
     -webkit-box-sizing: border-box;
     box-sizing: border-box;
}
html{/*! important comment */-webkit-box-sizing:border-box;box-sizing:border-box}