Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 722
ontk Avatar asked Oct 10 '12 06:10

ontk


1 Answers

You should add files to watch:

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

From example

like image 196
Ivan Dyachenko Avatar answered Nov 16 '22 01:11

Ivan Dyachenko