gruntjsgrunt-contrib-copy

grunt-contrib-copy: Multiple Copy Tasks


Was just wondering if it's possible to set the 'copy' task to do selective copies? Say, if one task wanted to target some files for copying, while another task may want to target others.

I see the 'main' is used in all the examples, but I can't find reference to if other names are able to be used, or another way to accomplish this, outside of using grunt-multi-dest

    copy: {
      main: {
        files: [
          {
            cwd: 'src_static/img/',
            src: ['**'],
            dest: '../mainProject/assets/img/'
          }
        ],
      onlyIcons: {
        files: [
          {
            cwd: 'src_static/img/icons/',
            src: ['**'],
            dest: '../mainProject/assets/img/icons/'
          }
        ],
      }
    }
    grunt.registerTask('copy-all', ['copy']);
    grunt.registerTask('copy-icons', ['copy:onlyIcons']);

Although closed, I was asked to reference the question I posted as an issue on the grunt-contrib-copy site: https://github.com/gruntjs/grunt-contrib-copy/issues/230#issuecomment-96467261

Thanks. -Keith


Solution

  • Looks like grunt-multi-dest appears to be the clear winner. Even then, there's not much downside to just including and using it. It fills the gap nicely.