alanshaw / grunt-include-replace

Grunt task to include files and replace variables. Allows for parameterised includes.
MIT License
200 stars 45 forks source link

I'd like an example for this use case: If my source file is in a nested folder, put the output directly in that folder instead of in the destination in a nested directory #18

Closed DanKaplanSES closed 11 years ago

DanKaplanSES commented 11 years ago

For example, if my file system looks like this:

Gruntfile.js
src/dir/dir2/myhtml.html
dist

If my configuration says this:

        includereplace: {
            taskname: {
                options: {

                },
                src: "src/dir/dir2/myhtml.html",
                dest: "dist"
            }
        }

It ends up putting myhtml.html in a directory like this:

dist/dir/dir2/myhtml.html

I want it to put it in a directory like this:

dist/myhtml.html

I can't figure out any way to accomplish this.

alanshaw commented 11 years ago

You want to use the flatten option. It's a grunt option for configuring your files list: http://gruntjs.com/configuring-tasks#building-the-files-object-dynamically

Your task should look like this:

includereplace: {
  taskname: {
    src: "src/dir/dir2/myhtml.html",
    dest: "dist",
    expand: true,
    flatten: true
  }
}