【问题标题】:Prevent Compilation of Unused LESS Class防止编译未使用的 LESS 类
【发布时间】:2017-08-06 17:38:44
【问题描述】:

我有一个基本的 mixin 类,我想在数百个类中使用它

.MainContentView {
  /*blah blah blah dee dah*/
}

.WorkspaceView1 {
  .MainContentView;
  .LightTealGradientBackground;
  /* blah blah blah hoo bah*/
}

但我不希望 MainContentView 出现在编译后的 CSS 中。我只是希望它在各种 WorkspacesView(n)s 中使用。所有这些在 HTML 中实际未使用但用于创建其他类的类不应出现在编译后的 CSS 中,因为它们只是开销。

令人惊讶的是,LESS Reference 并未涵盖此类示例。

【问题讨论】:

    标签: css class less mixins less-mixins


    【解决方案1】:

    Less 参考中有这个例子:

    Not Outputting the Mixin

    只需在 mixin 后面加上括号 ()

    .MainContentView() {
      /*blah blah blah dee dah*/
    }
    

    【讨论】:

    • 案件结束... :)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-08-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多