为Grunt Delta添加CoffeeScript支持?

时间:2013-08-04 20:53:03

标签: gruntjs

我能够编辑我的Gruntfile以使用grunt命令处理我的CoffeeScript文件,方法是添加:

grunt.initConfig({

  coffee: {
      compile: {
          options: {
              bare: true,
              join: true,
              sourceMap: true
          },

          files: {
              'src/coffee.js' : ['src/app/**/*.coffee', 'src/components/**/*.coffee']
          }
      }
  }, 
...

但我似乎无法弄清楚如何在Grunt Delta命令中添加CoffeeScript处理,因为我不想手动" grunt"每次我做出改变和测试。我当前的delta文件。如果让Delta使用CoffeeScript,我们会喜欢一些方向。

 delta: {
  /**
   * By default, we want the Live Reload to work for all tasks; this is
   * overridden in some tasks (like this file) where browser resources are
   * unaffected. It runs by default on port 35729.
   */
  options: {
    livereload: true
  },

  /**
   * When the Gruntfile changes, we just want to lint it. That said, the
   * watch will have to be restarted if it should take advantage of any of
   * the changes.
   */
  gruntfile: {
    files: 'Gruntfile.js',
    tasks: [ 'jshint:gruntfile' ],
    options: {
      livereload: false
    }
  },

  /**
   * When our source files change, we want to run most of our build tasks
   * (excepting uglification).
   */
  src: {
    files: [
      '<%= src.js %>'
    ],
    tasks: [ 'jshint:src', 'karma:unit:run', 'concat:dist', 'ngmin:dist', 'uglify:dist' ]
  },

  /**
   * When assets are changed, copy them. Note that this will *not* copy new
   * files, so this is probably not very useful.
   */
  assets: {
    files: [
      'src/assets/**/*'
    ],
    tasks: [ 'copy' ]
  },

  /**
   * When index.html changes, we need to compile just it.
   */
  html: {
    files: [ '<%= src.html %>' ],
    tasks: [ 'index' ]
  },

  /**
   * When our templates change, we only add them to the template cache.
   */
  tpls: {
    files: [
      '<%= src.atpl %>',
      '<%= src.ctpl %>'
    ],
    tasks: [ 'html2js', 'concat:dist', 'ngmin:dist', 'uglify:dist' ]
  },

  /**
   * When the CSS files change, we need to compile and minify just them.
   */
  sass: {
    files: [ 'src/**/*.scss' ],
    tasks: 'compassCompile'
  },

  envs: {
    files: [
      'environment.json'
    ],

    tasks: ['build']
  },

  /**
   * When a unit test file changes, we only want to linit it and run the
   * unit tests. However, since the `app` module requires the compiled
   * templates, we must also run the `html2js` task.
   */
  unittest: {
    files: [
      '<%= src.unit %>'
    ],
    tasks: [ 'jshint:test', 'karma:unit:run' ],
    options: {
      livereload: false
    }
  }
}

1 个答案:

答案 0 :(得分:0)

这就是我提出的:

   coffeesrc: {
        files: [
            'src/app/**/*.coffee', 'src/components/**/*.coffee'
        ],
        tasks: [ 'coffee' ]
    },

似乎工作。