我正在尝试复制这样的结构:
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}
]
我尝试过flatten选项,它从dest中删除'src'目录,但它也会删除其他目录并将每个文件放在dest的根级别。
我已经尝试将'cwd'设置为目标和源目录,但这似乎只是阻止了所有副本。
我敢肯定必须有一个选项允许这个,但我还没有找到它。有人有什么想法吗?
答案 0 :(得分:1)
我解决了。我需要从src中删除基目录并添加cwd:
即:
{src: ["src/*.js"], dest: buildDirectory, expand: true, cwd: srcDirectory}
而不是
{src: [srcDirectory+"src/*.js"], dest: buildDirectory, expand: true, cwd: srcDirectory}