【发布时间】:2016-02-12 04:34:15
【问题描述】:
我想使用 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',会正确复制所有文件,而且我确信我也可以使用 删除 ComponentC! strong>,但是我需要在我的 gulp.src 上定义每个组件,这样我就可以为每个网站编译一组文件。
gulp.task('copyHTMLnotUseful', function() {
return gulp.src([
'../Source/**.*.html',
'!../Source/ComponentB/**/*.html'
])
.pipe(gulp.dest('public_html'));
});
我试过设置 cwd 或 base,但也没有用。
谢谢
【问题讨论】: