Anshul
Anshul

Reputation: 9480

How can I zip a folder in grunt?

I have a folder "foo", but in my target folder "target" I want to send zip version of my "foo" folder such as "foo.zip", I google and found many way for zipping files but not for folder, so how can we zip a whole folder in grunt ?

Upvotes: 9

Views: 12082

Answers (2)

user372702
user372702

Reputation:

The accepted answer was throwing an error in grunt-contrib-compress 0.5.0. Try this instead:

compress: {
    foo: {
        options: {
            archive: './foo.zip',
            mode: 'zip'
        },
        files: [
            { src: './foo/**' }
        ]
    }
}

Upvotes: 24

Anshul
Anshul

Reputation: 9480

From above suggestion I am able to get my answer,We can use https://github.com/gruntjs/grunt-contrib-compress/ for zipping a folder.

compress: {
            zip:{ 
                  files: {
                            './foo.zip': './foo/**'
                         }
                }
          }

Upvotes: 4

Related Questions