【问题标题】:Copy a folder using cwd使用 cwd 复制文件夹
【发布时间】:2016-04-07 21:17:17
【问题描述】:
{ 
    expand: true,
    cwd: '/static',
    src: ['**'],
    dest: '../../public/'
}

我正在尝试将静态文件夹及其所有内容复制到公用文件夹,但以上仅复制静态文件夹内的内容。

如何在副本中也包含静态文件夹?

【问题讨论】:

    标签: javascript gruntjs grunt-contrib-copy


    【解决方案1】:

    来自Grunt docs:

     cwd: All src matches are relative to (but don't include) this path.
    

    以下来自 grunt-contrib-copy readme:

      // includes files within path
      {expand: true, src: ['path/*'], dest: 'dest/', filter: 'isFile'},
    
      // includes files within path and its sub-directories
      {expand: true, src: ['path/**'], dest: 'dest/'},
    

    【讨论】:

    • 谢谢 - filter: 'isFile' 有什么作用?
    • 过滤器属性允许您更准确地定位您想要复制的内容。您可以使用here 列出的任何方法。在您的情况下,您可能不想使用过滤器,因为您可能也需要目录。
    • @panthro,如果这对你有用,你能标记为正确吗?谢谢。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-07-17
    • 1970-01-01
    • 1970-01-01
    • 2011-10-05
    • 2013-11-25
    • 2018-12-17
    • 2015-09-20
    相关资源
    最近更新 更多