Can the gruntjs watch be restarted on grunt.js file change

◇◆丶佛笑我妖孽 提交于 2019-12-05 01:42:19
jakerella

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'] }
}

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'],
      }
 }

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

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