使用 gruntjs,如何观察 .coffee 文件中的变化



我是gruntjs的新手,这是我简单的gruntfile:

/* global module:false */
module.exports = function(grunt) {
  // Project configuration.
  grunt.initConfig({
    watch: {
      tasks: 'coffee'
    },
    coffee: {
      compile: {
        files: {
          'js/javascript/*.js': ['js/coffeescript/*.coffee'] // 1:1 compile
        }
      }
    }
  });
  grunt.loadNpmTasks('grunt-contrib-coffee');
  // Default task.
  grunt.registerTask('default', 'coffee');
};

当我运行咕噜声时,它可以很好地编译。但是,当我运行咕噜声手表时,它只是在等待,没有检测到我的更改。

您应该添加要监视的文件:

watch: {
  coffee: {
    files: ['js/coffeescript/*.coffee'],
    tasks: 'coffee'
  }
}

从示例

最新更新