mtpultz
mtpultz

Reputation: 18268

Expand not working in grunt-contrib-less task for dynamic selection

I've been playing with Grunt and one of the things I wanted to use it for was to compile my LESS files, but for some reason the expand: true (I commented everything out from the bottom up and it stopped throwing the err after commenting out expand) in the less:mini task is causing this error: Warning: Object true has no method 'indexOf' Use --force to continue. Does anyone know why this is happening? I can dynamically build the file object in grunt-contrib-copy no problem, and expand is required for the other options to work.

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
    }
  }
}

Thanks

Upvotes: 3

Views: 2383

Answers (1)

Kyle Robinson Young
Kyle Robinson Young

Reputation: 13762

files is intended to be used as an array or src-dest mappings. Grunt is interpreting the above properties within less.mini.files as src-dest mappings. See: http://gruntjs.com/configuring-tasks#files-object-format

You don't need to nest properties within files if you're not using that format. Modify your config to:

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
  }
}

Upvotes: 9

Related Questions