Copy folder structure from src / to dist / using grunt-contrib-copy

I have a folder structure that looks like this:

enter image description here

I want to copy folder img/

from src/

to folder dist/

.

I am using 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 like this. Missing image in icons folder:

enter image description here

Basically, I want to make a linux command (when I got to the root of my project):

cp -r src/img dist/img

      

How can i do this?

+3


source to share


2 answers


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'
                }
            ]
        }
    }

      

0


source


Solved it by following these steps:

copy:{

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


        ]
    }
}

      



Customization cwd

was necessary for this.

0


source







All Articles