4

I have a folder structure that looks like this

enter image description here

I want to copy the folder img/ from src/ to the dist/ folder.

I use the following grunt command, using grunt-contrib-copy:

copy:{
       main : {
                files : [
                    {
                        flatten : true,
                        expand: true,
                        src: ['src/img/*'],
                        dest: 'dist/img'
                    }
                ]
            }
        }

But my folder structure ends up like this. Missing the images in the icons folder:

enter image description here

Basically, I want to do the linux command (when I'm located in the root of my project):

cp -r src/img dist/img

How can I do this?

petur
  • 1,366
  • 3
  • 21
  • 42

2 Answers2

1

Set flatten to false flatten : false and change src to ['src/img/**'] to include subdirectories (source: https://github.com/gruntjs/grunt-contrib-copy)

copy:{
   main : {
            files : [
                {
                    flatten : false,
                    expand: true,
                    src: ['src/img/**'],
                    dest: 'dist/img'
                }
            ]
        }
    }
Thomas Roch
  • 1,208
  • 8
  • 19
0

Solved it by doing the following:

copy:{

    main : {
        files : [
            {
                cwd: 'src/',
                expand: true,
                src: ['img/**'],
                dest: 'dist/'
            }


        ]
    }
}

Setting the cwd was aparently needed for this to work.

petur
  • 1,366
  • 3
  • 21
  • 42