使用ant替换css的多个可变内容行
我有一个带有变量部分的 css 文件,当我运行构建脚本时,我想从文件中删除该变量部分(但我需要将该部分保留在源代码中)。我想我应该用某种标记将该部分包装在注释中(/*remove-front/&/remove-back*/),然后使用ant替换注释之间的所有内容什么也没有。
这是我的例子:
/* remove-front */
.footerGradients {
/* gradient settings (used http://www.colorzilla.com/gradient-editor/ to generate following code) */
background-color: #606869;
background: -webkit-gradient(linear, left bottom, left top, color-stop(0, #2f3838), color-stop(100%, #606869));
background: -moz-linear-gradient(center bottom, #2f3838 0, #606869 100%);
background: -ms-linear-gradient(center bottom, #2f3838 0, #606869 100%);
background: -o-linear-gradient(center bottom, #2f3838 0, #606869 100%);
background: linear-gradient(center bottom, #2f3838 0, #606869 100%);
-pie-background: linear-gradient(#2f3838, #606869);
filter: progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr=#2f3838,endColorstr=#606869);
/* end gradient settings */
}
.footerShadows {
/* box shadow settings (used http://css3generator.com/ to generate following code) */
-webkit-box-shadow: 0 0 2px 0 #293535;
-moz-box-shadow: 0 0 2px 0 #293535;
box-shadow: 0 0 2px 0 #293535;
/* end box shadow settings */
}
/* remove-back */
提前感谢您的回复。
I have a css file with a variable section that I want to remove from the file when I run my build script (but I'll need to keep the section in the source). I'm thinking I'd wrap the section in comments (/* remove-front / & / remove-back */) with some sort of tokens and then use ant to replace everything between the comments with nothing.
Here's my example:
/* remove-front */
.footerGradients {
/* gradient settings (used http://www.colorzilla.com/gradient-editor/ to generate following code) */
background-color: #606869;
background: -webkit-gradient(linear, left bottom, left top, color-stop(0, #2f3838), color-stop(100%, #606869));
background: -moz-linear-gradient(center bottom, #2f3838 0, #606869 100%);
background: -ms-linear-gradient(center bottom, #2f3838 0, #606869 100%);
background: -o-linear-gradient(center bottom, #2f3838 0, #606869 100%);
background: linear-gradient(center bottom, #2f3838 0, #606869 100%);
-pie-background: linear-gradient(#2f3838, #606869);
filter: progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr=#2f3838,endColorstr=#606869);
/* end gradient settings */
}
.footerShadows {
/* box shadow settings (used http://css3generator.com/ to generate following code) */
-webkit-box-shadow: 0 0 2px 0 #293535;
-moz-box-shadow: 0 0 2px 0 #293535;
box-shadow: 0 0 2px 0 #293535;
/* end box shadow settings */
}
/* remove-back */
Thanks in advance for your response.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我和@FailedDev有同样的想法,但是当尝试我的Eclipse时,它对“m”选项犹豫不决(并且我添加了使用
/*remove-front */
的功能(空格)和/*REMOVE-BACK*/
(不区分大小写):I had the same thought as @FailedDev, but when trying out my Eclipse, it was balking at the "m" option (and I've added a the ability to use
/*remove-front */
(spaces) and/*REMOVE-BACK*/
(case-insensitivity):我将使用标准的replaceregexp任务:
http://ant.apache.org/manual/Tasks /replaceregexp.html
I would use the standard replaceregexp task :
http://ant.apache.org/manual/Tasks/replaceregexp.html