[英]How to copy all images from a src folder to a dist folder recursively using copy files npm module?
Using the copy files command, how can I copy images (.png, .jpg) from a "src" folder to the "dist" folder, while preserving the same filepaths internally.使用复制文件命令,如何将图像(.png、.jpg)从“src”文件夹复制到“dist”文件夹,同时在内部保留相同的文件路径。 Should also work recursively.也应该递归工作。
https://www.npmjs.com/package/copyfiles https://www.npmjs.com/package/copyfiles
I have this我有这个
copyfiles(["src/**/*.png", "dist"], {u:2}, (err) => {
if (err) {
console.log("Error occurred while copying", err);
}
console.log("folder(s) copied to destination");
});
But it doesn't seem to work.但这似乎不起作用。 It creates the src
folder inside dist
folder.它在dist
文件夹中创建src
文件夹。
Thanks谢谢
Figured it out弄清楚了
copyfiles(["src/**/*.png", "dist"], 1, (err) => {
if (err) {
console.log("Error occurred while copying", err);
}
console.log("folder(s) copied to destination");
});
Accroding to the documentation in the README of copyfiles , if you want to provide options to copyfiles
as an object, you should provide full names of options:根据 copyfiles 的 README 中的文档,如果您想以 object 的形式提供copyfiles
的选项,则应提供选项的全名:
const copyOptions = { up: true, error: true };
copyfiles(["src/**/*.png", "dist"], copyOptions, (err) => {
if (err) {
return console.log("Error occurred while copying", err);
}
console.log("folder(s) copied to destination");
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.