【问题标题】:Grunt copying to location has full src path location appended, instead of just the dest propertyGrunt 复制到 location 附加了完整的 src 路径位置,而不仅仅是 dest 属性
【发布时间】:2014-05-22 18:14:30
【问题描述】:

我正在尝试执行以下操作:

FOLDERS.GRUNT = "js/grunt"

grunt.initConfig({
//copies from .tmp to final locations
    copy: {
      dist: {
        files: [{
          expand: true,
          dot: true,
          dest: FOLDERS.GRUNT,
          src: [
            FOLDERS.GRUNT + '/.tmp/*.js'

          ]
        }
        ]
      }
    },

我希望这些文件最终会出现在 js/grunt 中,但由于某种原因会出现在 js/grunt/js/grunt/.tmp/myfile.js 中

也尝试使用 cwd:FOLDERS.GRUNT,但遇到了同样的问题。

【问题讨论】:

    标签: node.js gruntjs grunt-contrib-copy


    【解决方案1】:

    这种方法可以在不展平目录的情况下工作。

    grunt.initConfig({
      copy: {
        dist: {
          files: [{
            cwd: FOLDERS.GRUNT + '/.tmp',
            expand: true,
            dest: FOLDERS.GRUNT,
            src: ['*.js']
          }]
        }
      }
    });
    

    【讨论】:

      【解决方案2】:

      答案其实很简单:

      使用:

      copy: {
        dist: {
          files: [{
            expand: true,
            dot: true,
            dest: FOLDERS.GRUNT,
            flatten: true,
            src: [
              FOLDERS.GRUNT + '/.tmp/*.js'
      
            ]
          }
          ]
        }
      },
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2021-09-05
        • 2021-06-01
        • 1970-01-01
        • 2015-11-14
        • 1970-01-01
        • 2018-06-01
        • 1970-01-01
        相关资源
        最近更新 更多