GWT 的 CSS 冗余检查器

发布于 2024-08-25 20:14:55 字数 326 浏览 4 评论 0原文

在我的项目中,我有很多 css 样式。其中一些从未使用过(不再使用)。我用 eclipse 手动检查:我选择文本,然后使用“搜索 -> 文本 -> 项目”我可以找到,如果这种样式仅出现在样式表中或也出现在 java 文件中。有没有更好的方法来检查我的 GWT 项目中当前使用了哪些样式?

编辑: @Igor,Keith:感谢您的提示,但我没有使用 CssResource 插入我的 css 文件。相反,我使用我的index.html。我想删除未使用的样式只是为了更好地概览。 CssResource 不完全是我正在寻找的。

In my project i have a lot of css styles. Some of them are never used (not anymore). I check this manually with eclipse: i select text and then with "Search -> Text -> Project" i can find, if this style occurs only in the stylesheet or also in java files. Is there better way to check, which styles are currently used in my GWT project?

edit:
@Igor,Keith: thanks for the hint, but i'm not using the CssResource to insert my css file. Instead i use my index.html. And i want to remove the unused styles just for better overview. CssResource is not exactly, what i'm looking for.

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

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

发布评论

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

评论(3

喜爱纠缠 2024-09-01 20:14:56

如果您使用 CssResource 来注入您的 css 文件,GWT 将为您修剪未使用的样式(就像处理未使用的代码一样)。默认情况下它也会对其进行混淆,所以要小心。有关全面的说明,请参阅文档

CssResourceUiBinder 结合使用效果最佳。我推荐这两个 - 你甚至可以获得很酷的功能,比如当你的 UiBinder xml 文件中缺少 CSS 样式(或者你拼写错误)时出现编译时错误,以及其他很酷/很棒的东西 - 再次检查 文档查看完整列表。

If you use CssResource to inject your css file, GWT will handle pruning unused styles for you (just like it does in the case of unused code). It will also by default obfuscate it, so watch out for that. For a comprehensive explanation see the docs.

CssResource works best in combination with UiBinder. I'd recommend both - you even get cool features like compilation-time errors when you are missing a CSS style in your UiBinder xml files (or you misspelled it), among other cool/awesome things - again, check the docs for the full list.

无可置疑 2024-09-01 20:14:56

GWT 2.0 添加了一个名为 ClientBundle 的功能,它是捆绑图像和 CSS 等资源文件的通用机制。如果将 CSS 文件与 ClientBundle 捆绑在一起(通过 CssResource 类),GWT 编译器实际上可能会在未使用的 CSS 选择器上生成错误。

该文档有点粗糙,但这里是 GWT 文档的相关部分:

http://code.google.com/webtoolkit/doc/latest/DevGuideClientBundle.html#Strict_scoping

除了检测缺失的选择器之外,CssResource 还补充了 CSS 本身,让您可以使用CSS 中的常量和条件,甚至允许您根据所使用的浏览器指定不同的样式。它还提供混淆和缩小等功能。

GWT 2.0 added a feature called ClientBundle, which is a generic mechanism for bundling resource files such as images and CSS. If you bundle CSS files with ClientBundle (via the CssResource class), the GWT compiler can actually generate errors on unused CSS selectors.

The documentation is a bit rough, but here is the relevant part of the GWT docs:

http://code.google.com/webtoolkit/doc/latest/DevGuideClientBundle.html#Strict_scoping

In addition to detecting missing selectors, CssResource also supplements CSS itself, letting you use constants and conditionals within your CSS, even allowing you to specify different styles depending on which browser is being used. It also provides obfuscation and minification, among other things.

北座城市 2024-09-01 20:14:56

我仍在寻找更好的解决方案。为了解决这个问题,我使用 linux 终端代替 eclipse 进行搜索,速度更快。

I'm still looking for a better solution. To solve the problem i've used the linux terminal instead eclipse for the search and that was faster.

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