随着几个 CSS 引导程序和样板的出现,是否没有一个程序可以抓取某个目录(元素、类、id)中的所有标签并从一个较少的文件中删除所有未使用的内容并编译为 CSS 文件?这不会节省大量空间吗?如果您知道,请告诉我。
编辑:我不是在谈论实时运行它或其他任何东西。对于我们这些预编译的人来说更多
我不知道,但我所做的是将事情组织在单独的文件中。这样我就可以只汇总特定视图所需的内容。我倾向于不太具体,所以我确定任何给定页面上都有未使用的规则。我可能拥有的一个基本示例是:
无基数
// 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 */
视图名.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 个样式表作为基础样式表和一个用于视图的样式表。在交付之前,所有内容都在服务器端进行编译和缩小