grunt-contrib-compress
Compress files and folders.
Getting Started
If you haven't used grunt before, be sure to check out the Getting Started guide, as it explains how to create a gruntfile as well as install and use grunt plugins. Once you're familiar with that process, install this plugin with this command:
npm install grunt-contrib-compress --save-dev
Compress task
Run this task with the grunt compress
command.
This task is a [multi task][] so any targets, files and options should be specified according to the [multi task][] documentation.
[multi task]: https://github.com/gruntjs/grunt/wiki/Configuring-tasks
Version 0.4.x
of this plugin is compatible with Grunt 0.4.x
. Version 0.3.x
of this plugin is compatible with Grunt 0.3.x
.
Node Libraries Used:
archiver (for zip/tar)
zlib (for gzip).
Options
archive
Type: String
This is used to define where to output the archive. Each target can only have one output file.
mode
Type: String
This is used to define which mode to use, currently supports gzip
, tar
, tgz
(tar gzip) and zip
.
Automatically detected per dest:src pair, but can be overridden per target if desired.
level (zip only)
Type: Integer
Default: 1
Sets the level of archive compression.
Currently, gzip compression related options are not supported due to deficiencies in node's zlib library.
Usage Examples
compress: {
main: {
options: {
archive: 'archive.zip'
},
files: [
{src: ['path/*'], dest: 'internal_folder/', filter: 'isFile'},
{src: ['path/**'], dest: 'internal_folder2/'},
{expand: true, cwd: 'path/', src: ['**'], dest: 'internal_folder3/'},
{flatten: true, src: ['path/**'], dest: 'internal_folder4/', filter: 'isFile'}
]
}
}
Release History
- 2013-01-22 v0.4.0rc7 Updating grunt/gruntplugin dependencies to rc7. Changing in-development grunt/gruntplugin dependency versions from tilde version ranges to specific versions.
- 2013-01-13 v0.4.0rc5 Updating to work with grunt v0.4.0rc5. Conversion to grunt v0.4 conventions. Replace basePath with cwd.
- 2012-10-11 v0.3.2 Rename grunt-contrib-lib dep to grunt-lib-contrib.
- 2012-10-08 v0.3.1 Replace zipstream package with archiver.
- 2012-09-23 v0.3.0 General cleanup. Options no longer accepted from global config key.
- 2012-09-17 v0.2.2 Test refactoring. No valid source check. Automatic mode detection.
- 2012-09-09 v0.2.0 Refactored from grunt-contrib into individual repo.
Task submitted by Chris Talkington
This file was generated on Wed Jan 23 2013 10:29:21.