使用Sass压缩输出,同时为Wordpress保留主题注释标题 [英] Using Sass compressed output while leaving theme comment header for Wordpress
问题描述
其他Wordpress主题开发人员如何在利用其压缩输出样式的同时将Sass纳入其主题开发中? Sass压缩会删除所有注释,因此我目前使用的主题声明为空style.css,并使用@import从罗盘中调用缩小的CSS,但这似乎不是最佳解决方案。
How do other Wordpress theme developers incorporate Sass into their theme development while taking advantage of its compressed output style? Sass compressed removes ALL comments, so I currently have an empty style.css with my theme declaration and an @import calling the minified css from compass, but this hardly seems like the best solution.
有人找到解决方法吗?否则,什么是最佳解决方案?
Has anybody found a way around this? What would be the best solution if not?
http ://codex.wordpress.org/Theme_Development#Theme_Stylesheet
http://sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html#id40
推荐答案
超级简短版本:使用 / *!大声的注释* /
并在打包和分发之前编译SCSS。
SUPER SHORT VERSION: Use /*! loud comments */
and compile the SCSS just before packaging and distributing.
两部分回答,首先是旧部分:
Two part answer, "old part" first:
在开发 Orin主题时,我使用了Sass / SCSS: https:/ /github.com/founddrama/orin
I used Sass/SCSS when developing my "Orin" theme: https://github.com/founddrama/orin
第一部分:
- 在我的
src / scss
目录中,我保留了所有的_include.scss
文件和具有所有@import
语句的style.scss
文件。 - 在开发过程中,我只运行了普通的
sass --watch
(尽管要记住保存style.scss这是一个额外的步骤,
文件)。 - 一旦您的SCSS源代码看起来不错并致力于版本控制,您只需构建
style.scss
放入style.css
,然后将其检入到已分发主题的版本控制中。
- In my
src/scss
directory, I keep all of my_include.scss
files and thestyle.scss
file that has all of the@import
statements. - During development, I just run the usual
sass --watch
(although it's an extra step to remember to save thestyle.scss
file). - Once your SCSS source is looking good and committed to version control, you can simply build the
style.scss
intostyle.css
and check that into version control for the Theme that gets distributed.
在我的cas中e, Orin仅适合我,因此当我在博客服务器上对其进行更新时,我将执行构建,但是在打包/分发之前,可以很容易地完成SCSS编译。我正在使用的构建脚本是此处(在该Github中回购);其要点是:
In my case, "Orin" is just for me, so I perform the build when I update it on the blog server, but the SCSS compilation can just as easily be done prior to packaging/distribution. The build script I'm using is here (in that Github repo); the gist of it being:
-
触摸
创建style.css
输出文件; - 应用许可证文本;
- 编译SCSS并将其附加到
style.css
。
touch
to create thestyle.css
output file;- apply the license text;
- compile the SCSS and append it to
style.css
.
第二部分:
Sass的最新版本包括对 / *的支持!大声的评论* /
;这意味着我需要下车然后更新为:
More recent versions of Sass include support for /*! loud comments */
; meaning that I need to get off my lazy butt and update to:
- 在<$ c $中包括许可证文本和主题描述c> style.scss 使用大声的注释;
- 更新构建/部署脚本以仅编译SCSS。
- Include the license text and theme description right there in
style.scss
using the loud comments; - update the build/deploy script to simply compile the SCSS.
这篇关于使用Sass压缩输出,同时为Wordpress保留主题注释标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!