css - 扩展在动态选择的 grunt-contrib-less 任务中不起作用

标签 css less gruntjs windows-7-x64

我一直在玩 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/

相关文章:

coffeescript - Grunt.js,警告 : Unable to write "src" file (Error code: EISDIR)

javascript - 如何在HTML、JS中通过鼠标点击改变矩形部分的颜色?

html - 使用 css 限制下拉列表中显示的选项

html - 在不影响导航栏或文本的情况下将背景图像变灰

html - 文本输入在我的 iPhone 上有 1 个像素的差异

php - 为什么简单地将 PHP 变量用于动态样式表?

css - 有没有办法在 Firebug 中显示 LESS CSS 代码(.less)?

已知脚本标签组合的 Javascript 正则表达式

javascript - UglifyJS 'use strict' 语句

css - 自定义 ionic 3 中的侧边菜单滚动条?