【问题标题】:grunt-uncss creating duplicate selectorsgrunt-uncss 创建重复的选择器
【发布时间】:2014-10-03 15:54:48
【问题描述】:

我正在使用 grunt-uncss 来清理我正在处理的 bootstrap / angularjs 项目中的 css 选择器。我正在使用 urls 选项,因为我需要 uncss 在运行时解析 css,因为它是一个角度应用程序。我也在使用 files 选项,因为没有它我无法让 uncss 工作。这导致我的CSS中有一些重复。这是我的配置:

uncss: {
  dist: {
    options: {
        urls: ['http://127.0.0.1:8282/build/index.html#/dashboard', 
               'http://127.0.0.1:8282/build/index.html#/servicedesk', 
               'http://127.0.0.1:8282/build/index.html#/email', 
               'http://127.0.0.1:8282/build/index.html#/calendar', 
               'http://127.0.0.1:8282/build/index.html#/customers']
    },
    files: {
      'build/css/raw/tidy.css': ['build/index.html']
    }
  }
}

index.html 有两个 css 文件,site.css 包含我所有的应用程序特定选择器和类,以及 bootstrap.css

当 uncss 运行时,它会复制许多选择器。例如,在 site.css 中只有一个

servicedesk {
  display: flex;
  width: 100%;
  height: 100%;
  flex-flow: column nowrap;
  justify-content: flex-start;
  align-items: flex-start;
  align-content: flex-start;
  flex: 1;
  margin: auto;
  padding: 1em;
}

它运行后有 2 个。我不知道为什么会发生这种情况,但我认为这是因为它处理了两次,一次在运行时处理,一次使用静态文件。不知道如何解决这个问题

【问题讨论】:

    标签: css node.js angularjs gruntjs


    【解决方案1】:

    在经过大量搜索后发现未解决的问题并在此处解决:https://github.com/addyosmani/grunt-uncss/issues/66

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-06-12
      相关资源
      最近更新 更多