DropCSS 介绍
Dropcss 是 一个 用来清理无用 css 的小工具,它根据 html 和 css 作为输入并返回那些有用到的 css 信息。 Dropcss 删除 所有未使用的样式块、重复的选择器、@keyframes等等。高度优化,速度极快。?
Dropcss安装
npm install -D dropcss
Dropcss使用 方法 :
const dropcss = require('dropcss');
let html = `
<html>
<head></head>
<body>
<p> Hello World! </p>
</body>
</html>
`;
let css = `
.card {
padding: 8px;
}
p:hover a:f irs t-child {
color: red;
}
`;
const whitelist = /#foo|.bar/;
let dropped = new Set();
let cleaned = dropcss({
html,
css,
shouldDrop: (sel) => {
if (whitelist.test(sel))
return false;
else {
dropped.add(sel);
return true;
}
},
});
console.log(cleaned.css);
console.log(dropped);
GitHub: https://github.com/leeoniya/dropcss
网站描述: 一个 用来清理无用 CSS 的小工具
DropCSS官方网站
官方网站:
如果觉得 网站内容还不错,欢迎将 网站 推荐给程序员好友。
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://haodehen.cn/did174478