Path Gulp丢失文件从Gulp.src(数组)到Gulp.dest的相对路径

Path Gulp丢失文件从Gulp.src(数组)到Gulp.dest的相对路径,path,gulp,base,cwd,Path,Gulp,Base,Cwd,我想使用gulp将src集合中的所有HTML从父目录复制并粘贴到子目录,但保留它们的路径 Project +-- /Development | +- gulpfile.js | +-- /Source +- /ComponentA | +- /DirA | +- fileA.html | +- /ComponentB | +- /DirB | +- fileB.html | +- /Component

我想使用gulp将src集合中的所有HTML从父目录复制并粘贴到子目录,但保留它们的路径

Project
+-- /Development
|   +- gulpfile.js
|
+-- /Source
    +- /ComponentA
    |  +- /DirA
    |     +- fileA.html
    |
    +- /ComponentB
    |  +- /DirB
    |     +- fileB.html
    |
    +- /ComponentC
       +- /DirC
          +- fileC.html
我需要gulp将所有HTML文件复制到Development/public\u HTML

Project
+-- /Development
    +- gulpfile.js
    |
    +- /public_html 
        +- /ComponentA
        |  +- /DirA
        |  +- fileA.html
        |
        +- /ComponentC
           +- /DirC
              +- fileC.html
我的吞咽任务

gulp.task('copyHTMLwrong', function() {
    return gulp.src([
        '../Source/ComponentA/**/*.html',
        '../Source/ComponentC/**/*.html'
    ])
    .pipe(gulp.dest('public_html'));
});
但我得到(宽松的路径):

PS:我知道如果我使用'Source/***.html',将正确复制所有文件,我确信我也可以使用删除组件C,但我需要在我的gulp.src上定义每个组件,以便为每个网站编译一组文件

我尝试了setcwdbase,但都不起作用


谢谢

我想出了如何使用base来解决我的问题

很简单,只需添加一个带有_dirname的基,如下所示。 只需确保在path.resolve()内设置:

Project
+-- /Development
    +- gulpfile.js
    |
    +- /public_html 
        +- fileA.html
        +- fileC.html
gulp.task('copyHTMLnotUseful', function() {
    return gulp.src([
        '../Source/**.*.html',
        '!../Source/ComponentB/**/*.html'
    ])
    .pipe(gulp.dest('public_html'));
});
gulp.task('copyHTML', function() {
    return gulp.src([
        '../Source/ComponentA/**/*.html',
        '../Source/ComponentC/**/*.html'
    ],
    {base: path.resolve(__dirname + '/../Source')})
    .pipe(gulp.dest('public_html'));
});