Using gruntjs, how do watch for changes in .coffee files?

情到浓时终转凉″ 提交于 2019-12-10 12:48:11

问题


I am new to gruntjs and here is my simple 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');
};

When I run grunt it compiles fine. However, when I run grunt watch, it's just waiting and not detecting my changes.


回答1:


You should add files to watch:

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

From example



来源:https://stackoverflow.com/questions/12813514/using-gruntjs-how-do-watch-for-changes-in-coffee-files

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!