我一直在玩 Grunt,我想用它做的一件事是编译我的 LESS 文件,但出于某种原因 expand: true (我从下往上注释了所有内容,它停止抛出在 less:mini 任务中注释掉 expand) 后出错导致此错误:警告:对象 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
如果您不使用那种格式,则不需要在文件
中嵌套属性。将您的配置修改为:
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
}
}
关于css - 扩展在动态选择的 grunt-contrib-less 任务中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20592078/