grunt: Watch and synchronize files

I want to run a local sync daemon.

It should watch src directory and copy any changed file to dst directory. There are many subdirectories in src, so the relative paths should be preserved. All necessary subdirectories in dst are already created.

I want to filter for *.js files only.

I've found a grunt-sync tool. The documentation is so short that I even don't know if it fits me. Here's my Gruntfile:

module.exports = function (grunt) {

        sync: {
          main: {
            files: [{
                cwd: src,
                src: ['**/*.js'],
                dest: dst

    grunt.registerTask('default', 'sync');


When I run grunt, I see no watch task. Grunt freezes for several seconds, then copies all files and exits. And I want a watch-sync daemon.


I created a tool called duplicate which will do what you want (though a year later), it copies all matching files when start, and keep watching if there would be any changes.

It's not written as a Gulp or Grunt plugin because it doesn't need to be, but of course you may easily run it in a Gulp or Grunt task.

Check out

Need Your Help

How to handle singular resources with RESTAdapter

rest ember.js ember-data

How are singular resources handled in ember-data? Say I have the following RESTful routes:

object references an unsaved transient instance error

java hibernate java-ee jpa jboss

Ok so i want to get mapped Groups and student in one table but i've got an error: "object references an unsaved transient instance". If i add cascade to all it will say that this objects arleady ex...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.