我一直在玩Grunt,其中一个我想用它来编译我的LESS文件,但由于某种原因扩展:true(我从底部向上评论了所有内容,它在评论后停止抛出错误在less中: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 } } }
谢谢
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 } }