繁体   English   中英

在 Grunt 中复制特定目录名称格式下的所有文件?

[英]Copy all files under specific directory name format in Grunt?

我在整个应用程序的 t9n 目录下都有翻译文件……在某些组件目录等中。

app
components
    ComponentA
        t9n
            translations_A.json
    ComponentB
        t9n
            translations_B.json
t9n
    common-translations.json
    

而且我正在寻找创建一个繁重的任务来在构建应用程序时将所有这些.json 文件复制到assets目录中。

有没有办法获取特定目录名称下的所有内容? 所以我可以说....对于 app 下的每个目录,获取任何t9n目录的内容?

我知道你可以做一些事情,比如......

"**/*.{png}"表示复制所有 PNG 文件....但不确定上面的内容是什么。

答案就像评论中提到的那样, "app/**/t9n/*.json特别是我对 Grunt https://gruntjs.com/configuring-tasks#globbing-patterns的通配模式感到困惑

我最终使用了 grunt 文档https://gruntjs.com/configuring-tasks#files-array-format中的文件数组格式

最后得到了这样的东西......

  "build-t9n": {
    files: [
      {
        cwd: "src/app/js",
        src: ["**/t9n/*.json"],
        dest: "build/assets/t9n",
        expand: true
      }
    ]
  }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM