使用Gulp.Dest()时如何省略所有子目录?
我在Gulp中有一项任务:
// converts jpg/png images to webp
function webpImage() {
return src('src/**/*.{jpg,png}')
.pipe(imagewebp())
.pipe(dest('dist/images'));
}
我想要的就是将所有新的.webp图像直接放入DIST/图像中。我不想要任何子文件夹,类似的路径:dist/images/header/header.jpg。我需要这样的:/dist/images/header.jpg
我尝试使用src()的基本选项做点事位于图像。
I've got a task in Gulp:
// converts jpg/png images to webp
function webpImage() {
return src('src/**/*.{jpg,png}')
.pipe(imagewebp())
.pipe(dest('dist/images'));
}
All I want is to put all the new .webp images directly into dist/images. I don't want any sub folders, paths like this: dist/images/header/header.jpg. I need it to be like this: /dist/images/header.jpg
I've tried to do something with the base option of src() and it didn't work out because I don't know how to get full path of located image.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
查看 gulp-flatten 软件包。我已经有一段时间没有使用过,因此请确保它与Gulp V4一起使用。它“使”文件的目录结构“变平”,以消除所需的尽可能多的父目录。
Look at the gulp-flatten package. I haven't used it for a while so make sure it works with gulp v4. It "flattens" the directory structure of the files passing through to eliminate as many parent directories as you need.