I would suggest improving the Atillas solution. Restoring all templates with each change is not optimal, and you will be disappointed in large projects.
Here is what should help:
Use the new plugin to process only modified files
Install: npm install grunt-newer --save-dev
Docs: https://www.npmjs.org/package/grunt-newer#optionsoverride
Using
- prefix tasks with new:
- add grunt.loadNpmTasks ('grunt-newer); to gruntfile
- use the override option to check (the magic you are looking for)
newer: { options: { override: function (detail, include) { if (detail.task === 'jade') { checkForModifiedImports(detail.path, detail.time, include); } else { include(false); } } } }
Using the clock to detect file changes
Install: npm install grunt-contrib-watch --save-dev Docs: https://www.npmjs.org/package/grunt-contrib-watch
Application:
- add grunt.loadNpmTasks ('grunt-contrib-watch'); to gruntfile
- the task might look something like this.
watch: { scripts: { files: '**/*.jade', tasks: ['newer:jade'], options: { interrupt: true }, }, }
source share