微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

DropCSS

编程之家收集整理的这个编程导航主要介绍了DropCSS编程之家,现在分享给大家,也给大家做个参考。

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:first-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

官方网站:

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。