node.js - 使用 grunt-contrib-copy 将文件夹结构从 src/复制到 dist/

标签 node.js gruntjs grunt-contrib-copy

我的文件夹结构是这样的

enter image description here

我想将文件夹img/src/复制到dist/文件夹。

我使用以下 grunt 命令,使用 grunt-contrib-copy :

copy:{
       main : {
                files : [
                    {
                        flatten : true,
                        expand: true,
                        src: ['src/img/*'],
                        dest: 'dist/img'
                    }
                ]
            }
        }

但我的文件夹结构最终是这样的。缺少图标文件夹中的图像:

enter image description here

基本上,我想执行 linux 命令(当我位于项目的根目录时):

cp -r src/img dist/img

我该怎么做?

最佳答案

将 flatten 设置为 false flatten : false 并将 src 更改为 ['src/img/**'] 以包含子目录(来源:https://github.com/gruntjs/grunt-contrib-copy)

copy:{
   main : {
            files : [
                {
                    flatten : false,
                    expand: true,
                    src: ['src/img/**'],
                    dest: 'dist/img'
                }
            ]
        }
    }

关于node.js - 使用 grunt-contrib-copy 将文件夹结构从 src/复制到 dist/,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30071985/

相关文章:

node.js - Docker 构建需要很长时间来构建 nodejs 应用程序

gruntjs - Uglify JS 意外 token 运算符 <<->>,预期 punc << : >>

css - 使用 Grunt Compass 任务生成没有调试信息的生产 CSS 代码

gruntjs - 指定cwd选项时,grunt-contrib-copy任务失败

javascript - 从我的自定义任务运行任务?

node.js - 从 browserify 和 uglify 生成 sourcemap

node.js - 如何回滚一天?

node.js - ENOENT : no such file or directory when running npm install command

node.js - 将环境变量从 grunt 传递到文件

javascript - Grunt复制/ Ant 模式/省略变量目录