How do you watch multiple files, but only run task on changed file, in Grunt.js?

前端 未结 7 1865
盖世英雄少女心
盖世英雄少女心 2020-12-01 00:12

In learning how to use grunt, I am trying to make a simple coffee-script watcher/compiler. The problem is, if I tell the watch task to watch several files, and

7条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-01 00:48

    https://github.com/tschaub/grunt-newer looks like exactly for similar tasks:

    Configure Grunt tasks to run with newer files only.

    Synopsis: The newer task will configure another task to run with src files that are a) newer than the dest files or b) newer than the last successful run (if there are no dest files). See below for examples and more detail.

    You can prepend easily to any task. In your case:

      grunt.loadNpmTasks('grunt-newer');
      grunt.registerTask('default', 'newer:coffee');
    

提交回复
热议问题