12

Can the grunt watch be restarted when ever there is a change in grunt.js file

use case: I am right now in the process of building my grunt process and keep changing the grunt.js file and I have to restart the grunt.js to see if it works.

mido
  • 24,198
  • 15
  • 92
  • 117
user3140435
  • 147
  • 1
  • 7

3 Answers3

13

It looks like this was implemented in version 0.4.0. You can see the issue here which explains that by simply watching the Gruntfile (even without any tasks) the entire contents of the Grunt setup will be reloaded:

watch: {
    grunt: { files: ['grunt.js'] }
}
Pavlo
  • 43,301
  • 14
  • 77
  • 113
Jordan Kasper
  • 13,153
  • 3
  • 36
  • 55
1

Yes you can achieve it. For example add Gruntfile.js to your files array.

 watch: {
     js:{
        files:['src/js/**/*.js','Gruntfile.js'],
        tasks: ['jshint','requirejs'],
      }
 }
msapkal
  • 8,268
  • 2
  • 31
  • 48
0

This default behaviour is to reload only when the Gruntfile changes.

If you want to reload when an other files change you can use the option reload :

watch: {

        "grunt" : {
            files: ['Gruntfile.js','someotherfiles.json'],
            options: { reload: true }
        }

    },

Source : https://github.com/gruntjs/grunt-contrib-watch/pull/285

gsouf
  • 901
  • 10
  • 25
  • This is specially useful when you split the grunt configuration (usually inside Gruntfile.js) into separate files. – Meetai.com Jul 17 '16 at 20:15