简体   繁体   English

如何使用复制文件 npm 模块将所有图像从 src 文件夹递归复制到 dist 文件夹?

[英]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.

相关问题 如何将公用文件夹从src复制到dist文件夹 - How to copy public folder from src to dist folder 如何将CSS文件从源文件夹捆绑和复制到dist文件夹? - How to bundle and copy CSS files from source folder to dist folder? 如何使用Webpack将脚本文件从src复制到dist - How to copy script files from src to dist using webpack 观看模板文件并将它们复制到 dist/ 文件夹 - Watch template files and copy them to dist/ folder 使用Gulp将NPM模块/库复制到分发文件夹 - Copy NPM module/library to distribution folder using Gulp 如何告诉Lineman将所有文件从/ dist复制到另一个目录? - How to tell Lineman to copy all files from /dist to a different directory? webpack - 捆绑/复制所有要构建的资产或dist文件夹 - webpack - bundle / copy all assets to build or dist folder 有没有办法将所有脚本从Bower组件复制到grunt中的dist / script文件夹而无需缩小? - Is there any way to copy all the scripts from the bower components to dist/script folder in grunt without minification? 如何复制文件夹中的文件进行构建? - How to copy files in a folder to build? 谷歌应用脚本将所有数据从一个文件夹复制到另一个文件夹并防止脚本复制已经存在的文件 - Google apps script to copy all data from a folder to another folder and prevent script copy files that already exist
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM