grunt-contrib-watch
grunt-contrib-watch copied to clipboard
Multiple watch configurations?
Trying to set up different watch configurations for dev vs prod What am I missing?
Verifying property watch.dev.files exists in config...ERROR
>> Unable to process task.
Warning: Required config property "watch.dev.files" missing.
concurrent: {
dev: {
tasks: ['nodemon', 'watch:dev'],
options: {
logConcurrentOutput: true
}
},
prod: {
tasks: ['nodemon', 'watch:prod'],
options: {
logConcurrentOutput: true
}
}
},
watch: {
prod: {
js: {
files: [
'editor/js/**/*.js'
],
tasks: ['copy:build', 'concat', 'uglify', 'attachCopyright:js']
},
sass: {
files: [
'editor/sass/**/*.scss'
],
tasks: ['sass', 'attachCopyright:css']
},
json: {
files: [
'nodes/core/locales/en-US/messages.json',
'red/api/locales/en-US/editor.json',
'red/runtime/locales/en-US/runtime.json'
],
tasks: ['jsonlint:messages']
},
keymaps: {
files: [
'editor/js/keymap.json'
],
tasks: ['jsonlint:keymaps', 'copy:build']
},
misc: {
files: [
'CHANGELOG.md'
],
tasks: ['copy:build']
}
},
dev: {
js: {
files: [
'editor/js/**/*.js'
],
tasks: ['copy:build', 'concat', 'babel']
},
sass: {
files: [
'editor/sass/**/*.scss'
],
tasks: ['sass', 'attachCopyright:css']
},
json: {
files: [
'nodes/core/locales/en-US/messages.json',
'red/api/locales/en-US/editor.json',
'red/runtime/locales/en-US/runtime.json'
],
tasks: ['jsonlint:messages']
},
keymaps: {
files: [
'editor/js/keymap.json'
],
tasks: ['jsonlint:keymaps', 'copy:build']
},
misc: {
files: [
'CHANGELOG.md'
],
tasks: ['copy:build']
}
}
This is too many levels deep.
watch: {
prod: {
js: {
Can you prefix your watch tasks with 'prod_' or 'dev_', then call them like so:
tasks: ['nodemon', 'watch:dev_js', 'watch:dev_sass']
tasks: ['nodemon', 'watch:dev_js', 'watch:dev_sass']
doesn't work, it will only run the first watch task (watch:dev_js in this case)
Hey i had the same issue and did the same logic as you but that didn't work. The working solution and working like a charm is this one: https://stackoverflow.com/questions/13833196/gruntjs-watch-different-folders-and-execute-tasks Hope this helps. you need to install the grunt plugin: https://www.npmjs.com/package/grunt-focus then add like you tried with concurrent: this code
focus: { develop: { include: ['dev'] }, master: { include: ['prod'] }, },
and make ure tasks like this:
grunt.registerTask('dev', 'compile develop', ['focus:develop']); grunt.registerTask('prod', 'compile production', ['focus:master']);