如何检查重复的CSS规则? [英] How to check for duplicate CSS rules?

查看:609
本文介绍了如何检查重复的CSS规则?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我搞砸了我的CSS,不知何故,我有很多重复的规则,我的1800的行css文件现在是3000+行..

I messed up my css and somehow i have a lot of the duplicate rules and my 1800 something lines css file is now of 3000+ lines..

任何方式/工具,将我的css文件作为输入,并检查所有重复的规则?并可能生成一个删除这些冗余的css?

Is there any way/tool that would take my css file as input and check for all the duplicate rules? and possibly generate a css removing those redundancies?

推荐答案

安装节点JS
https://nodejs.org/en/download/

如果您已安装node js或

if you have already node js installed or after installing open node command prompt window by typing node( on windows machine) in start.

键入以下命令以安装css清除工具

Type following command to install css purge tool



npm install css-purge -g

npm install css-purge -g


安装工具后,

打开节点命令提示符窗口打开的文件夹,并粘贴css文件,然后键入以下命令在节点cmd提示窗口

Open the folder where node command prompt window is open and paste messed up css file there and then type following command in node cmd prompt window



css-purge -i style.css -o style_purged.css

css-purge -i style.css -o style_purged.css


其中style.css是乱七八糟的css文件的名称,上述命令将创建一个新的css文件名称为style_purged.css,其中不包含重复的css规则。

where style.css is the name of messed up css file, the above command will create a new css file with name style_purged.css which does not contain duplicate css rules.

但请注意,它也会删除您的注释。
https://www.npmjs.com/package/css-purge

But be careful, it will also remove the comments you have. https://www.npmjs.com/package/css-purge

这篇关于如何检查重复的CSS规则?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆