Reputation: 47051
In a Gruntfile.js, I saw codes like this:
watch: {
jsTest: {
files: ['test/spec/{,*/}*.js'],
tasks: ['newer:jshint:test', 'karma']
},
gruntfile: {
files: ['Gruntfile.js']
},
livereload: {
options: {
livereload: '<%= connect.options.livereload %>'
},
files: [
'<%= yeoman.app %>/{,*/}*.html',
'.tmp/styles/{,*/}*.css',
'<%= yeoman.app %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}'
]
}
},
I really can't understand this part
gruntfile: { files: ['Gruntfile.js'] },
And the following livereload
part..
It seems that it wants to watch Gruntfile.js
but didn't assign any tasks
option to it. So nothing will happen when Gruntfile.js
is changed.. Then what is the point to add this to the watch
list?
Upvotes: 2
Views: 34
Reputation: 13273
They implemented a new feature in version 0.4.0 to allow reloading of all Grunt configuration when the Gruntfile.js
file changes. To do so, no task may be specified.
In other words, if you were to specify the tasks
option, then Grunt would not reload its own configuration when changed. The way you have it, all config will be updated when Gruntfile.js itself changes.
For example, if you are watching some JS files and you change the config for your jsTest
task (for example, you add a new folder of files to watch), then because you are also watching Gruntfile.js
your new jsTest
config will be automatically reloaded without having to stop and start the watch
task.
Upvotes: 1