【问题标题】:Uncss Ignore option isn't workingUncss忽略选项不起作用
【发布时间】:2015-02-15 06:46:54
【问题描述】:

我正在尝试使用 uncss 删除 css,但它会删除所有样式,无论它们是否列在 ignore 数组中。

我要比较的 2 个文件只是索引和 app.min.js,其中包含嵌入在 javascript 中的所有模板作为字符串,这些模板是使用 $templateCache 配置的

看看 grunt 任务,也许我缺少一些明显的东西:

uncss:{
    production: {
        options: {
            ignore: ['.someclass', '.someclass', '.someclass','.etc_etc_class'],
            stylesheets:['app.min.css']
        },
        files: {
            'dist/app.min.css':['dist/index.html','dist/app.min.js']
        }        
    }
}

欢迎任何评论!

【问题讨论】:

    标签: angularjs gruntjs uncss


    【解决方案1】:

    样式表选项应该具有相对于根目录的 css 文件的完整路径。因此,如果文件位于 dist/ 中,请将其添加到样式表选项中。

    例如:

    uncss: {
      dist: {
        options: {
          ignore       : ['#added_at_runtime', /test\-[0-9]+/],
          media        : ['(min-width: 700px) handheld and (orientation: landscape)'],
          raw          : 'h1 { color: green }',
          stylesheets  : ['lib/bootstrap/dist/css/bootstrap.css', 'src/public/css/main.css'],
          ignoreSheets : [/fonts.googleapis/],
          urls         : ['http://localhost:3000/mypage', '...'], // Deprecated
          timeout      : 1000,
          htmlroot     : 'public',
          report       : 'min'
        },
        files: {
          'dist/css/tidy.css': ['app/index.html', 'app/about.html']
        }
      }
    }
    

    见:https://github.com/addyosmani/grunt-uncss

    【讨论】:

    • 我的问题是 ignoreSheets 不起作用。我试图忽略 index.css,而我的 ignoreSheets 行如下所示:ignoreSheets : [/index/],。但它什么也没做。路径无关紧要,因为它只是匹配单词“index”。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-01-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-11-28
    • 2013-05-16
    相关资源
    最近更新 更多