grunt-contrib-copy: Files copied to wrong path

I find that the behavior of this plugin is very strange. I have the following task configuration in my grunt file:

        copy:
        {
            bootstrap: {
                files: [
                    {
                        src: ['components/bootstrap/img/*'],
                        dest: 'web/img/bootstrap/'
                    }
                ]
            }
        }

One would expect that components/bootstrap/img/myFile.png is copied to web/img/bootstrap/myFile.png. But it’s being copied to web/img/components/bootstrap/img/myFile.png.

Is this the normal behavior, or am I doing something wrong ?

About this issue

  • Original URL
  • State: closed
  • Created 11 years ago
  • Comments: 19 (6 by maintainers)

Most upvoted comments

To recap the answers to @webberig’s initial question: Instead of:

    copy: {
        bootstrap: {
            files: [
                {
                    src: ['components/bootstrap/img/*'],
                    dest: 'web/img/bootstrap/'
                }
            ]
        }
    }

try the following:

    copy: {
        bootstrap: {
            files: [
                {
                    expand: true,
                    cwd: 'components/bootstrap/img/'
                    src: ['*'],
                    dest: 'web/img/bootstrap/'
                }
            ]
        }
    }

With this setup, a file components/bootstrap/img/myFile.png is copied to web/img/bootstrap/myFile.png.