扩展不适用于动态选择的grunt-contrib-less任务

时间:2013-12-15 06:57:04

标签: css less gruntjs windows-7-x64

我一直在玩Grunt,其中一个我想用它来编译我的LESS文件,但由于某种原因扩展:true(我从底部向上评论了所有内容并且它停止了抛出错误地评论出扩展后错误:mini任务导致此错误:警告:对象true没有方法'indexOf'使用--force继续。有谁知道为什么会这样?我可以在grunt-contrib-copy中动态构建文件对象没问题,并且需要展开才能使其他选项工作。

less: { // Set up to detect files dynamically versus statically

  mini: {
    options: {
      cleancss: true, // minify
        report: 'min' // minification results
    },
    files: {
      expand: true, // set to true to enable options following options:
        cwd: "dev/less/", // all sources relative to this path
        src: "*.less", // source folder patterns to match, relative to cwd
        dest: "dev/css/", // destination folder path prefix
        ext: ".css", // replace any existing extension with this value in dest folder
        flatten: true  // flatten folder structure to single level
    }
  }
}

由于

1 个答案:

答案 0 :(得分:9)

files旨在用作数组或src-dest映射。 Grunt将less.mini.files中的上述属性解释为src-dest映射。请参阅:http://gruntjs.com/configuring-tasks#files-object-format

如果您不使用该格式,则无需在files内嵌套属性。将配置修改为:

less: { // Set up to detect files dynamically versus statically
  mini: {
    options: {
      cleancss: true, // minify
        report: 'min' // minification results
    },
    expand: true, // set to true to enable options following options:
    cwd: "dev/less/", // all sources relative to this path
    src: "*.less", // source folder patterns to match, relative to cwd
    dest: "dev/css/", // destination folder path prefix
    ext: ".css", // replace any existing extension with this value in dest folder
    flatten: true  // flatten folder structure to single level
  }
}