Grunt - grunt-contrib-copy copies containing folder structure as well and how to set Current Working Directory (CWD)

I recently gave the npm package grunt-contrib-copy a go. I had some issues with it creating a folder level more than I would have expected. This turns out to be due to it copying from the current working directory.

I found the following two posts on the issue and it took me some time to figure it out:

I tried the above but none of it worked. What the posts did not say is that the CWD means "current working directory"! In my example I have the following folder structure and the result I want:

Root
---website //Gruntfile located here
------css
------js
------index.html
------page.html
---gruntfile.js
---build
------css //expected newly created
------js //expected newly created
------index.html //expected newly created
------page.html //expected newly created

So I am executing my grunt commands from "root". However when copy is run from this location it takes the "website" folder with it. That I did not want. I wanted what is portrayed in the above. In order to do this I needed to understand the cwd parameter. This has to be set to "website/" in the above, so my current working directory is "website/". Then I can just set "**" as source. That gave me the above result. My grunt task look like the following:

copy: {
    main: {
        files: [
            {
                expand: true,
                cwd: 'website/', //This is the important part
                src: ['**'],
                dest: '../build/'
            },
        ],
    },
},

I hope this helps you and if it does, please let me know in the comments!