I'm having trouble configuring Grunt to watch my project files, rebuild and update a page hosted in a connect server. If I run any of the build tasks and then 'watch'
as part of a combined task, then 'watch'
seems to get stuck in a loop, endlessly printing the message.
Running "watch" task
Waiting...
Warning: must provide pattern
If instead I just run $ grunt watch
, it will happily watch my source files and compile/build as appropriate.
I think the relevant task configurations are these:
watch: {
html: {
files: [ '<%= site.partials %>', '<%= site.layouts %>', '<%= site.pages %>' ],
tasks: [ 'html' ]
},
sass: {
files: [ '<%= site.src %>sass/*.scss' ],
tasks: [ 'styles' ]
}
},
// development server
connect: {
options: {
port: 8080,
livereload: 35729,
hostname: 'localhost',
},
dev: {
options: {
directory: 'build',
}
}
},
and the task definitions:
grunt.registerTask( 'build', [ 'styles', 'html', ] );
grunt.registerTask( 'default', [ 'build','connect:dev', 'watch' ] );
The 'styles'
and 'html'
tasks run grunt-sass and assemble. As stated above, running any of these tasks, or even 'watch'
on its own yields the expected results. This suggests my config object has site.partials
, site.dest
etc defined correctly. The problem only happens when I run any task and then 'watch'
, as in the default task.
site
object. However, without seeing that part of yourgrunt.initConfig
call, I really can't say. I know this question is old now, but can you either post your entire Gruntfile or, if you've solved the problem, post your answer? – Blunt