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 规则?


基础教程推荐
- 直接将值设置为滑块 2022-01-01
- 自定义 XMLHttpRequest.prototype.open 2022-01-01
- 我可以在浏览器中与Babel一起使用ES模块,而不捆绑我的代码吗? 2022-01-01
- 如何使用JIT在顺风css中使用布局变体? 2022-01-01
- html表格如何通过更改悬停边框来突出显示列? 2022-01-01
- Electron 将 Node.js 和 Chromium 上下文结合起来意味着 2022-01-01
- 如何使用TypeScrip将固定承诺数组中的项设置为可选 2022-01-01
- 用于 Twitter 小部件宽度的 HTML/CSS 2022-01-01
- Chart.js 在线性图表上拖动点 2022-01-01
- Vue 3 – <过渡>渲染不能动画的非元素根节点 2022-01-01