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

查看:318
本文介绍了如何检查重复的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/

如果您有已经安装了节点js或者在启动时通过键入节点(在Windows机器上)安装打开的节点命令提示符窗口。

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文件的名称,上面的命令将创建一个名为style_purged.css的新的css文件,其中d不包含重复的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天全站免登陆