我有一个简单的吞咽任务,它将文件夹树从node-modules移动到特定的目标,保持文件夹结构如下:
function libraries(){
let libPaths = [
'./node_modules/jquery/dist/**/*.*', // Note: copying the ``dist`` folder
'./node_modules/bootstrap-icons/**/*.*' // Note: copying the module
]
return gulp.src(libPaths, {base: './node_modules/'})
.pipe(gulp.dest(
(vinyl) => {
// Something here?
return '/destination/'
}
)
);
}结果:
destination
├── bootstrap-icons
│ ├── LICENSE.md
│ ├── README.md
│ ├── bootstrap-icons.svg
│ ├── font
│ ├── icons
│ └── package.json
└── jquery
└── dist // <- problem
├── jquery.js
├── jquery.min.js
├── jquery.min.map
├── jquery.slim.js
├── jquery.slim.min.js
└── jquery.slim.min.map期望:
destination
├── bootstrap-icons
│ ├── LICENSE.md
│ ├── README.md
│ ├── bootstrap-icons.svg
│ ├── font
│ ├── icons
│ └── package.json
└── jquery
├── jquery.js
├── jquery.min.js
├── jquery.min.map
├── jquery.slim.js
├── jquery.slim.min.js
└── jquery.slim.min.map如何检测源文件何时在dist/内,例如./node_modules/jquery/dist/jquery.js,以便将目标输出设置为/destination/jquery/jquery.js --而不是在/destination/jquery/dist/jquery.js内。
发布于 2021-02-15 15:47:11
我让它像这样工作:
function libraries(){
let libPaths = [
'./node_modules/jquery/dist/**/*.*', // Note: copying the ``dist`` folder
'./node_modules/bootstrap-icons/**/*.*' // Note: copying the module
]
return gulp.src(libPaths, {base: './node_modules/'})
.pipe(gulp.dest(
(vinyl) => {
vinyl.path = path.join(
vinyl.cwd, vinyl.base,
vinyl.relative.replace('dist\\', ''));
return '/destination/'
}
)
);
}https://stackoverflow.com/questions/66174089
复制相似问题