使用 Ant RegEx 查找引用的 CSS 文件,然后将该列表用作文件集
我有一个用于测试的 CSS 文件。它@导入我的所有样式表:
@import "css/structure.css"
@import "css/typography.css"
@import "css/forms.css"
这让我可以测试样式和更改,但以一种您永远不想要的方式。
当我“构建”这个项目时,我想找到所有这些引用(RegEx css/(.*?.css)),然后使用该列表作为文件集来合并和压缩。
奇怪的是,合并和压缩是最简单的部分。我完全不知道如何使用 RegEx 来构建我的文件集。
如果我必须访问 .properties 文件,我会的,但我希望有一些可以更加自动化的东西。
感谢任何想法……
——内特
I have a CSS file that I use for testing. It @imports all of my stylesheets:
@import "css/structure.css"
@import "css/typography.css"
@import "css/forms.css"
This lets me test the styling and changes, but in a way that you'd never want live.
When I "build" this project, I'd like to find all of these references (RegEx css/(.*?.css)) and then use that list as a FileSet to then merge and compress.
The merging and compressing are, oddly, the easiest part. I'm at a complete loss on how to use RegEx to build my FileSet.
If I have to go to a .properties file, I will, but I was hoping for something that could be more automated.
Appreciate any thoughts...
—Nate
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
标准文件通配符不起作用吗?您是否尝试过:
请参阅 FileSet 类型文档 了解更多信息。
Is standard file globbing not working? Have you tried:
See the FileSet Type documentation for more info.
我远不是一个伟大的 RegEx'er,但我想我找到了我的解决方案:
我创建了一个目标来加载我的主 styles.css 文件,从中抓取各个文件并将其全部放在以逗号分隔的属性中:
这会导致 ${list.css} =“one.css、two.css、struction.css 等.css”,然后我可以将其用作文件列表/文件集。
它不漂亮,但很有效。我希望我可以将正则表达式重写为更强大的东西(现在,你忘记了分号或使用单引号,它就被破坏了)......但是乞丐不能是选择者!
感谢您的帮助 hoipolloi!
新西兰
I'm far and away not a great RegEx'er, but I think I found my solution:
I created a target that loads my main styles.css file, scrapes the individual files from it and places it all in a comma-separated property:
That results in ${list.css} = "one.css, two.css, structure.css, etc.css" which I can then use as a file list / file set.
It isn't pretty, but it works. I wish I could rewrite that RegEx to something more robust (right now, you forget a semi-colon or use single quotes and it's busted) ... but beggars can't be choosers!
Thanks for the help hoipolloi!
nz