Grunt copy task can not retain directory structure

2.6k views Asked by At

I am using Bower to install the dependencies of my project and grab only the files I need with Grunt.js and copy them to the static to be served by the application.

One of them is the MathJax library but when I try to copy the whole folder (see the code below) it just ignores the directories and sprays all the files into the destination without handling the MathJax directory structure.

copy: {
    MathJax: {
        expand: true,
        flatten: true,
        cwd: 'bower_components/MathJax/',
        src: ['**'],
        dest: 'base/static/MathJax/'
    }
}

Is it a common bug on the copy task of Grunt or am I doing something wrong?

1

There are 1 answers

1
Sindre Sorhus On BEST ANSWER

You're using the flatten options which does what it says; flattens the directory structure.

See docs: Building the files object dynamically