grunt.js - Multiple destinations when minifying files

gruntjs, javascript, node.js

Solution

I'd use grunt-contrib-copy plugin:

Install with npm:

npm install grunt-contrib-copy

Modify `grunt.js` (add copy task definition and load copy plugin):

    ...
    copy: {
        dist: {
            files: {
                'example/js/vendor/': 'dist/precook.min.js'
            }
        }
    }
    ...

grunt.loadNpmTasks('grunt-contrib-copy');

Optionally register `copy` in to grunt's default task.

The added beauty here is that you can now perform all other copy tasks as well. Even patterns are supported, like copy all minified files (`'dist/*.min.js'`).

Problem

My grunt.js has a typical minification task: ``` min: { dist: { src: ['dist/precook.js'], dest: 'dist/precook.min.js' } } ``` What is the simplest way to have multiple dest files? I'd like to minify into: - dist/precook.min.js - example/js/vendor/precook.min.js The built-in min task doesn't appear to support multiple destinations, so I assume this can be achieved via a simple "copy" task. Can someone please point me in the right direction?

Original source