2014-11-03 93 views
0

還有源文件夾文件夾和發佈文件夾中的項目。我想從源複製所有文件和文件夾進行發佈。從Gruntfiles.js用grunt跳過源文件夾複製文件

enter image description here

相關代碼:

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

    grunt.loadNpmTasks('grunt-contrib-copy'); 
    grunt.registerTask('default', ['copy']); 

但是它拷貝文件夾本身並提出在發佈文件夾。

enter image description here

嘗試了很多的變化,從grunt-copy文件並不能找到解決辦法。

回答

1

試試這個配置:

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

如果你想只複製SRC的某些部分,並建立在正常流動的其他人(SASS,CONCAT,縮小插件),你可以選擇:

copy: { 
    main: { 
    files: [ 
     {expand: true, cwd: '../src/', src: ['images/*'], dest: '../public/images'}, 
     ... 
    ] 
    } 
} 

上面的關鍵是CWD,它允許您按照原樣複製文件夾,而不是複製「public」中的「src」。

相關問題