gruntjsgrunt-contrib-copy

Copy a folder with files and folders


I have a subdir and in there, there are many more folders and files. So what I want is to copy the subdir with all the folders and files.

This is what it looks like now:

.
├── Gruntfile.js
└── src
    ├── a
    └── subdir
        └── b
        └──subdir2
           └── c
        └──subdir3
           └── d
           └──subdir4
              └── e

This is how I want it to look after using Grunt:

.
├── Gruntfile.js
└── src
    ├── a
    └── subdir
        └── b
        └──subdir2
           └── c
        └──subdir3
           └── d
           └──subdir4
              └── e
└── dist
    └── subdir
        └── b
        └──subdir2
           └── c
        └──subdir3
           └── d
           └──subdir4
              └── e

This is what I've tried so far, but it just isn't working. It copies everything also src folder and file a:

copy: {
        expand: true,
        src: 'src/subdir/*',
        dest: 'dist/'
}

Solution

  • Use:

    {
      expand: true,
      cwd: 'src/',
      src: 'subdir/**',
      dest: 'dist/'
    },
    

    The cwd option is here for that