alanshaw / grunt-include-replace

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

Destination can't be a file #23

Closed Soviut closed 10 years ago

Soviut commented 10 years ago

I've tried and tried but I can't seem to get the dest to be anything but a directory. I'd really like to be able to select a single file, replace a few variables in it, and then output it to a new file in the same directory. I don't want to overwrite the old file so I need to be able to provide a destination file name, however every attempt I've made has resulted in new directories being created instead.

Even the grunt files object method doesn't work:

files: {
    '<% yeoman.appScripts %>/app.min.js': '<% yeoman.appScripts %>/app.js'
}

(Yes, I'm calling my destination file .min.js because I need to call it something different and I plan to minify it immediately afterwards anyways)

alanshaw commented 10 years ago

You should be able to do this using the ext option.

includereplace: {
    dist: {
        src: "app.js",
        dest: "<% yeoman.appScripts %>",
        expand: true,
        cwd: "<% yeoman.appScripts %>",
        ext: ".min.js"
    }
}
Soviut commented 10 years ago

I forgot about ext! This would probably be a good example to put in the documentation since there may be others like me looking to process a single file this way.

In the long term, it would be really nice if the files object approach were supported since it's far simpler.