watch single file and compile if a dependency changes
zsitro opened this issue · 3 comments
Hi, I can't find in the guide how to add a watch task for a single styl file and make it compile when an imported styl file has changed.
For example:
watch: {
stylesheets: {
files: 'source/main.styl',
tasks: [ 'stylesheets' ]
},
}
If main.styl
has an @import "dependency1"
and I change dependency1.styl
the main.styl
won't be compiled like the regular stylus command-line watcher would do which would watch every changes in imported files..
Can anyone advise on this? Thanks in advance!
The stylus command line watcher knows how to process the stylus dependency tree because it was built for stylus. Watch is a general use utility--it doesn't know how to trace dependencies for every type of input you might ultimately invoke a task for. You'll need to provide the dependency listing yourself. Thankfully, Grunt has great built-in utilities for handling complex globbing: http://gruntjs.com/configuring-tasks
Whoops, the link I meant to send was:
http://gruntjs.com/configuring-tasks#globbing-patterns
Thanks, I managed to do this :)
watch files: 'source/**/*.styl'
and bind it to a stylus task with src: [ 'main.styl']