将注释添加到 SASS/Compass 输出

发布于 2024-10-08 22:42:00 字数 436 浏览 0 评论 0原文

有没有一种方便的方法让 SASS 自动在每个 CSS 输出文件的开头添加注释?具体来说,当使用 Compass 时,我想贴一个简短的警告,告诉设计师不要直接编辑 CSS,并向他们指示如何开始使用 Compass。我使用 :compressed 输出样式,它会删除输入 SCSS/SASS 文件中的注释。

如果没有方便的方法来执行此操作,那么我将提交问题/补丁。我正在考虑添加一个名为 :output_prefix 的 选项 接受一个字符串,该字符串将被添加到所有输出 CSS 文件的前面。

Is there a convenient way to have SASS automatically prepend a comment to the beginning of each CSS output file? Specifically, when using Compasss I'd like to stick a brief warning telling designers not to edit the CSS directly and to point them to instructions on getting started with Compass. I use an output style of :compressed, which strips out comments that are in the input SCSS/SASS file.

If there isn't a convenient way to do this then I'll submit an issue/patch. I was thinking of adding an option named :output_prefix that takes a String that will be prepended to all output CSS files.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

空城缀染半城烟沙 2024-10-15 22:42:00

来自评论上的 SASS 参考:

当注释的第一个字母是 ! 时,即使在压缩输出模式下,注释也会被插入并始终渲染到 css 输出中。这对于将版权声明添加到生成的 CSS 非常有用。

所以你可以用这样的东西开始你的 SASS 文件:

/*!
 * WARNING: Don't edit this file by hand! Instead, you should be using Compass.
 * (More information at http://compass-style.org/)
 */

From the SASS reference on comments:

When the first letter of a comment is !, the comment will be interpolated and always rendered into css output even in compressed output modes. This is useful for adding Copyright notices to your generated CSS.

So you could start your SASS file with something like this:

/*!
 * WARNING: Don't edit this file by hand! Instead, you should be using Compass.
 * (More information at http://compass-style.org/)
 */
朦胧时间 2024-10-15 22:42:00

压缩删除所有评论。我建议您将其放入属性中:

warning { do-not: "edit this file"; }

关于提议的补丁,我认为这个用例没有足够的说服力来保证这样的功能。

compressed strips out all comments. I suggest you put this in a property:

warning { do-not: "edit this file"; }

Regarding the proposed patch, I do not think this use case is compelling enough to warrant such a feature.

小猫一只 2024-10-15 22:42:00

Sass 中的已知错误。在 master 中已修复但尚未发布:

https://github.com/nex3/sass/issues/784

Known bug in Sass. Fixed in master but not yet released:

https://github.com/nex3/sass/issues/784

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文