Grunt递归拷贝 [英] Grunt recursive copy

查看:92
本文介绍了Grunt递归拷贝的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在设置一个Grunt脚本,需要将图像的目录从A复制到B,足够简单。

目录结构:

组件


  • componentA

    • js
    • img

      • imgfolderA

      • imgfolderB


    • css


    • imgfolderA





每个img目录都可以包含这些目录中的其他目录和目录,以帮助组织图像。



我想使用Grunt来获取所有这些图像并将其放入他们在一个目录下(assets / img):

资产
$ b


  • img

    • dirA

      • imgfolderA

      • imgfolderB


      • dirB

        • imgfolderA





        关于如何在不指定每个组件的情况下在grunt中执行此操作的任何想法d irectory(它需要完全自动化)?

        解决方案

        使用 grunt.file.expand



        只需传递匹配的glob模式(例如 ** / img / ** ),然后在返回的匹配文件值上进行复制。


        I'm setting up a Grunt script that needs to copy and reorganise directories of images from A to B. Simple enough.

        Directory structure:

        components

        • componentA
          • js
          • img
            • imgfolderA
            • imgfolderB
          • css
        • componentB
          • js
          • img
            • imgfolderA

        Each img directory could contain other directories and directories within those directories to help organise the images.

        I want to use Grunt to take all those images and put them under one directory (assets/img):

        assets

        • img
          • dirA
            • imgfolderA
            • imgfolderB
          • dirB
            • imgfolderA

        Any ideas on how could I do this in grunt without specifying each component directory (it needs to be fully automated)?

        解决方案

        This is rather simple using grunt.file.expand.

        Just pass matching glob patterns (e.g. **/img/**), and then recurse on the returned matching file values to copy.

        这篇关于Grunt递归拷贝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆