我想使用 gulp 从父目录到子目录的 src 集合中复制和粘贴所有 HTML,但保留它们的路径
Project
+-- /Development
| +- gulpfile.js
|
+-- /Source
+- /ComponentA
| +- /DirA
| +- fileA.html
|
+- /ComponentB
| +- /DirB
| +- fileB.html
|
+- /ComponentC
+- /DirC
+- fileC.html
我需要 gulp 将所有 HTML 文件复制到Development/public_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'));
});
但我得到(松散的路径):
Project
+-- /Development
+- gulpfile.js
|
+- /public_html
+- fileA.html
+- fileC.html
PS:我知道如果我使用'Source/**/*.html',将正确复制所有文件,我相信我也可以使用! ,但我需要在我的gulp.src上定义每个组件,这样我就可以为每个网站编译一组文件。
gulp.task('copyHTMLnotUseful', function() {
return gulp.src([
'../Source/**.*.html',
'!../Source/ComponentB/**/*.html'
])
.pipe(gulp.dest('public_html'));
});
我试过 set cwd或base,但也没有用。
谢谢