Reputation: 2777
Is there a way to specify file dependencies in Grunt? I.e. if I have:
global/page.jade
project/index.jade -- includes global/page.jade
project/about.jade -- includes global/page.jade
project/test.jade
and I change global/page.jade
then I would like to get project/index|about.jade
recompiled. I checked out the plugins but couldn't find anything that would provide that functionality.
Upvotes: 4
Views: 667
Reputation: 29
I'd suggest enhancing Atillas solution. Rebuilding all templates on every change isn't optimal and will piss you off on large projects.
Install: npm install grunt-newer --save-dev
Docs: https://www.npmjs.org/package/grunt-newer#optionsoverride
Usage:
newer: {
options: {
override: function (detail, include) {
if (detail.task === 'jade') {
checkForModifiedImports(detail.path, detail.time, include);
} else {
include(false);
}
}
}
}
Install: npm install grunt-contrib-watch --save-dev
Docs: https://www.npmjs.org/package/grunt-contrib-watch
Usage:
watch: {
scripts: {
files: '**/*.jade',
tasks: ['newer:jade'],
options: {
interrupt: true
},
},
}
Upvotes: 2
Reputation: 14701
grunt watch use in your gruntfile.js in following way
...
watch: {
scripts: {
files: 'src/**/*',
tasks: ['buildDevelopment'],
options: {
interrupt: true,
},
}
grunt.registerTask('buildDevelopment', ['clean'
,'jade'
,'copy:development'
,'bowercopy:development'
]);
...
Upvotes: 5