我需要查找和删除页面上未使用的类(在html中未使用,但在css中存在)。我尝试使用此解决方案,但它说所有类都在我的站点的html中使用。我的CSS分为几个文件。
我认为您可以在这里使用此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'
};
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句