Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/silverlight/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Gruntjs 使用grunt跳过源文件夹复制文件_Gruntjs_Grunt Contrib Copy - Fatal编程技术网

Gruntjs 使用grunt跳过源文件夹复制文件

Gruntjs 使用grunt跳过源文件夹复制文件,gruntjs,grunt-contrib-copy,Gruntjs,Grunt Contrib Copy,项目中有源文件夹和发布文件夹。我想将所有文件和文件夹从源复制到发布 Grunfiles.js中的相关代码: grunt.initConfig({ copy: { main: { files: [ { src: ['source/**/*'], dest: 'publish/'}, ] } } }); grunt.loadNpmTasks(

项目中有源文件夹和发布文件夹。我想将所有文件和文件夹从源复制到发布

Grunfiles.js中的相关代码:

grunt.initConfig({
        copy: {
          main: {
            files: [
              { src: ['source/**/*'], dest: 'publish/'},
              ]
          }
      }
});

    grunt.loadNpmTasks('grunt-contrib-copy');
    grunt.registerTask('default', ['copy']);
但是,它复制源文件夹本身并将其放入发布文件夹中


尝试了文档中的许多变体,但找不到解决方案。

尝试此配置:

grunt.initConfig({
    copy: {
        main: {
            cwd: 'source',
            src: ['**/*'],
            dest: 'publish/',
            expand: true
        }
    }
});

如果您只想复制SRC的某些部分,并在正常流程上构建其他部分(SASS、CONCAT、MINIFY插件),您可以选择:

copy: {
  main: {
    files: [
      {expand: true, cwd: '../src/', src: ['images/*'], dest: '../public/images'},
      ...
    ]
  }
}
上面的关键点是CWD,它允许您按原样复制文件夹,而不是复制“public”中的“src”