Copying everything recursively with grunt-contrib-copy, omitting part of the structure?

147 views Asked by At

Say I have this directory setup:

 +-- gruntfile.js
 |    
 +-- src/
 |  |  
 |  +-- lib/
 |     |
 |     +-- imgs/**
 |     |
 |     +-- js/**

And I want to create a distribution folder using grunt-contrib-copy:

 +-- gruntfile.js
 |    
 +-- app/
 |  |  
 |  +-- lib/
 |     |
 |     +-- imgs/**
 |     |
 |     +-- js/**
 |
 +-- src/**

Note that the src folder is not listed within the dist folder. So far, all my efforts end up like this:

 +-- gruntfile.js
 |    
 +-- app/
 |  |  
 |  +-- src/
 |     |
 |     +-- lib/
 |        |
 |        +-- imgs/**
 |        |
 |        +-- js/**
 +-- src/**

I've tried many different configurations, but here's the one I'm on currently:

{
  expand: true,
  src: ['src/lib/**'],
  dest: 'app/',
  flatten: false,
  filter: 'isFile'
}

Remember that I want to copy everything recursively below src into app, but without the src folder coming with it.

1

There are 1 answers

2
Matthew Bakaitis On BEST ANSWER

Add the cwd property to your config and modify the src, so it looks like this:

{
  expand: true,
  cwd: 'src/',
  src: ['lib/**'],
  dest: 'app/',
  flatten: false,
  filter: 'isFile'
}