Grunt 配置里的 src 和 dest 具体对应什么意思?


比如下边的配置, 因为 Grunt 支持 src dest 的写法, 于是我用了:


 module.exports = (grunt) ->
  grunt.initConfig
    coffee:
      options:
        bare: yes
      compile:
        files: [
          cwd: 'long/long/path/coffee/'
          src: ['**']
          dest: 'long/long/path/js/'
          ext: '.js'
          filter: 'isFile'
        ]

    stylus:
      compile:
        files: [
          cwd: 'long/long/path/stylus/'
          src: ['**']
          dest: 'long/long/path/css/'
        ]

结果运行 Grunt 报错了, 其他的具体配置我省略了:


 >> Source file "a.styl" not found.
>> Source file "b.styl" not found.
>> Source file "c.styl" not found.
>> Source file "d.styl" not found.
>> Source file "e.styl" not found.
>> Source file "f.styl" not found.

具体的文件 a.styl 等, 在 long/long/path/stylus/ 是验证了存在的, 只能推测是处理相对路径时 Grunt 转成了其他路径

主要是 src dest pwd 在 Grunt 里, 他们是全局生效的配置语法吗?

我的场景里, 希望代码从 x 路径批量编译代码到 y 路径, 应该怎样写配置?


后来发现原因是 expand 参数没写.. 参数没有正确展开

grunt web前端开发

未馴化D猫樣 11 years, 11 months ago

Your Answer