Integrate grunt sync with grunt watch

The following is a sample of gruntfile configuration for grunt sync integrates with grunt watch:

  
module.exports = function (grunt) {
  grunt.loadNpmTasks('grunt-sync');
  grunt.initConfig({
    sync: {
      fonts: {
        files: [{
          cwd: "bower_components/fontawsome/fonts",
          src: ['**'],
          dest: "sites/default/themes/custom/bootstrap_sub/fonts",
        }], // files
        verbose: true,
        pretend: false,
        failOnError: true,
        updateAndDelete: true,
        compareUsing: "md5" // Options "md5" or "mtime"
      } // fonts
    }, // sync
    watch: {
      syncfiles: {
        files: [
          "bower_components/fontawsome/fonts/**",
        ],
        tasks: ['sync']
      } // syncfiles
    } // watch
  }); // initConfig
  grunt.registerTask('default', 'watch');
  grunt.registerTask('prod', ['sync']);
} // exports
  

Comments

I wasn't able to run the sync task separately from watch. Including 'syncfiles' solved the issue. Thanks for posting.

Add new comment

Restricted HTML

  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
  • Lines and paragraphs break automatically.