Javascript grunt contrib将复制目录复制到另一个没有根目录的目录中

Javascript grunt contrib将复制目录复制到另一个没有根目录的目录中,javascript,gruntjs,grunt-contrib-copy,Javascript,Gruntjs,Grunt Contrib Copy,我试图复制这样一个结构: src |-a |-b |-c ||-ca ||-cb dest |-a |-b |-c ||-ca ||-cb 然而,如果没有src目录本身出现在dest目录中,我似乎无法实现这一点。即 src |-a |-b |-c ||-ca ||-cb dest |src ||-a ||-b ||-c |||-ca |||-cb 我的复制配置设置如下: files: [ {src: [targetDirectory+"index.html"], dest: buil

我试图复制这样一个结构:

src
|-a
|-b
|-c
||-ca
||-cb
dest
|-a
|-b
|-c
||-ca
||-cb
然而,如果没有src目录本身出现在dest目录中,我似乎无法实现这一点。即

src
|-a
|-b
|-c
||-ca
||-cb
dest
|src
||-a
||-b
||-c
|||-ca
|||-cb
我的复制配置设置如下:

files: [
    {src: [targetDirectory+"index.html"], dest: buildDirectory, expand: true},
    {src: [targetDirectory+"*.png"], dest: buildDirectory, expand: true},
    {src: [targetDirectory+minJSDestination], dest: buildDirectory, expand: true},
    {src: [targetDirectory+minCSSDestination], dest: buildDirectory, expand: true},
    {src: [targetDirectory+"assets/fonts/**.*"], dest: buildDirectory, expand: true},
    {src: [targetDirectory+"assets/images/**.*"], dest: buildDirectory, expand: true},
    {src: [targetDirectory+"assets/partials/**.*"], dest: buildDirectory, expand: true},
    {src: [targetDirectory+"src/*.js"], dest: buildDirectory, expand: true}
]
我尝试过扁平化选项,它从dest中删除'src'目录,但它也会删除其他目录,并将每个文件放在dest的根级别

我尝试将“cwd”设置为目标目录和源目录,但这似乎阻止了所有的复制


我相信一定有一个选项允许这样做,但我还没有找到它。有人有什么想法吗?

我解决了。我需要从src中删除基本目录并将其添加到cwd中:

即:

而不是

{src: [srcDirectory+"src/*.js"], dest: buildDirectory, expand: true, cwd: srcDirectory}

同样的问题,同样的解决方案。cwd失踪。遗憾的是,任务手册中甚至没有提到此参数。此参数可能重复
{src: [srcDirectory+"src/*.js"], dest: buildDirectory, expand: true, cwd: srcDirectory}