是否有一个程序可以查看LESS和PHP / HTML文件,并删除未使用的CSS

时间:2012-09-27 19:09:31

标签: php html css less

随着几个CSS bootstraps和boilerplates的出现,没有一个程序会抓取某个目录(element,class,id)中的所有标签,并从较少的文件中删除未使用的所有内容并编译为a CSS文件?会不会节省大量空间?如果您知道,请告诉我。

编辑:我不是在谈论现场直播或其他什么。更多我们这些预编译的人

1 个答案:

答案 0 :(得分:1)

我不知道,但我所做的是将事情整理成单独的文件。这样我只能卷起特定视图所需的内容。我倾向于不太具体,但我确定在任何给定的页面上都有未使用的规则。我可能拥有的一个基本例子是:

base.less

// this is the sheet for the global layout and is needed for every page

@import "reset.less";
@import "util.less"; // these are all mixins for grids, clearfix, gradients, etc..
@import "typography.less"; // fontface, basic typo grid
@import "brand.less"; //mixins for colors, brand specific sprites, etc..
@import "components.less"; // these are rules for components that might be used anywhere

/* rules for global layout and default element styles follow */

viewname.less

// this is the view/page specific sheet
@import "util.less"; // these are all mixins for grids, clearfix, gradients, etc..
@import "typography.less"; // fontface, basic typo grid
@import "brand.less"; //mixins for colors, brand specific sprites, etc..
@import "viewname.components.less"; // set of component styles used only for this view

viewname.components.less

// this is a "roll up" sheet that imports different componets used in this specific view
// this way i can each component separate but still use them in different views.
@import "somewidget.component.less";
@import "someotherwidget.component.less";

那么基本上我只包括2个样式表基础和一个视图。在交付之前,所有内容都在服务器端进行编译和缩小