2016-11-11 61 views
0

我需要查找和删除页面上未使用的类(未在html中使用,但在css中)。我试图使用this解决方案,但它说我的网站上的所有类都用在html中。我的CSS分成几个文件。在css中删除未使用的类

+3

问题是,并非所有的CSS跨不同的浏览器(媒体查询,-moz-什么的,等)在同一页上使用 – dandavis

回答

2

我认为你可以使用这个在这里uncss - >https://www.npmjs.com/package/uncss这样的:

var uncss = require('uncss'); 

var files = ['my', 'array', 'of', 'HTML', 'files', 'or', 'http://urls.com'], 
    options = { 
     ignore  : ['#added_at_runtime', /test\-[0-9]+/], 
     media  : ['(min-width: 700px) handheld and (orientation: landscape)'], 
     csspath  : '../public/css/', 
     raw   : 'h1 { color: green }', 
     stylesheets : ['lib/bootstrap/dist/css/bootstrap.css', 'src/public/css/main.css'], 
     ignoreSheets : [/fonts.googleapis/], 
     timeout  : 1000, 
     htmlroot  : 'public', 
     report  : false, 
     uncssrc  : '.uncssrc' 
    };