How to check for duplicate CSS rules?(如何检查重复的 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?
推荐答案
安装Node JShttps://nodejs.org/en/download/
如果您已经安装了 node js,或者在安装打开 node 命令提示符窗口后通过在 start 中键入 node(在 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 purge 工具
Type following command to install css purge tool
npm install css-purge -g
npm install css-purge -g
工具安装后,
打开节点命令提示符窗口所在的文件夹并粘贴混乱的 css 文件,然后在节点命令提示符窗口中键入以下命令
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 文件,其中不包含重复的 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 规则?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何检查重复的 CSS 规则?
基础教程推荐
- 为什么我在 Vue.js 中得到 ERR_CONNECTION_TIMED_OUT? 2022-01-01
- jQuery File Upload - 如何识别所有文件何时上传 2022-01-01
- 如何使用sencha Touch2在单页中显示列表和其他标签 2022-01-01
- Node.js 有没有好的索引/搜索引擎? 2022-01-01
- 什么是不使用 jQuery 的经验技术原因? 2022-01-01
- Javascript 在多个元素上单击事件侦听器并获取目标 2022-01-01
- 如何使用 CSS 显示和隐藏 div? 2022-01-01
- 如何在特定日期之前获取消息? 2022-01-01
- 每次设置弹出窗口的焦点 2022-01-01
- WatchKit 支持 html 吗?有没有像 UIWebview 这样的控制器? 2022-01-01
