{"id":13596436,"url":"https://github.com/gruntjs/grunt-contrib-compress","last_synced_at":"2025-05-15T00:10:57.454Z","repository":{"id":4580992,"uuid":"5722848","full_name":"gruntjs/grunt-contrib-compress","owner":"gruntjs","description":"Compress files and folders.","archived":false,"fork":false,"pushed_at":"2024-07-02T05:12:14.000Z","size":663,"stargazers_count":345,"open_issues_count":19,"forks_count":109,"subscribers_count":11,"default_branch":"main","last_synced_at":"2025-03-13T14:07:04.317Z","etag":null,"topics":["hacktoberfest"],"latest_commit_sha":null,"homepage":"http://gruntjs.com/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gruntjs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE-MIT","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":"AUTHORS","dei":null,"publiccode":null,"codemeta":null}},"created_at":"2012-09-07T21:44:12.000Z","updated_at":"2025-02-28T03:02:43.000Z","dependencies_parsed_at":"2024-08-01T16:41:22.434Z","dependency_job_id":null,"html_url":"https://github.com/gruntjs/grunt-contrib-compress","commit_stats":{"total_commits":221,"total_committers":38,"mean_commits":5.815789473684211,"dds":0.8054298642533937,"last_synced_commit":"4a3e7b55f121def55947c699374129cc4677cf0b"},"previous_names":[],"tags_count":23,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gruntjs%2Fgrunt-contrib-compress","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gruntjs%2Fgrunt-contrib-compress/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gruntjs%2Fgrunt-contrib-compress/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gruntjs%2Fgrunt-contrib-compress/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gruntjs","download_url":"https://codeload.github.com/gruntjs/grunt-contrib-compress/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244637085,"owners_count":20485445,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hacktoberfest"],"created_at":"2024-08-01T16:02:26.472Z","updated_at":"2025-03-27T16:10:38.628Z","avatar_url":"https://github.com/gruntjs.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# grunt-contrib-compress v2.0.0 [![Build Status](https://github.com/gruntjs/grunt-contrib-compress/workflows/Tests/badge.svg)](https://github.com/gruntjs/grunt-contrib-compress/actions?workflow=Tests)\n\n\u003e Compress files and folders\n\n\n\n## Getting Started\n\nIf you haven't used [Grunt](https://gruntjs.com/) before, be sure to check out the [Getting Started](https://gruntjs.com/getting-started) guide, as it explains how to create a [Gruntfile](https://gruntjs.com/sample-gruntfile) as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:\n\n```shell\nnpm install grunt-contrib-compress --save-dev\n```\n\nOnce the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:\n\n```js\ngrunt.loadNpmTasks('grunt-contrib-compress');\n```\n\n*This plugin was designed to work with Grunt \u003e= 0.4.x. If you're still using grunt v0.3.x it's strongly recommended that [you upgrade](http://gruntjs.com/upgrading-from-0.3-to-0.4), but in case you can't please use [v0.3.2](https://github.com/gruntjs/grunt-contrib-compress/tree/grunt-0.3-stable).*\n\n\n\n## Compress task\n_Run this task with the `grunt compress` command._\n\nTask targets, files and options may be specified according to the grunt [Configuring tasks](http://gruntjs.com/configuring-tasks) guide.\n\nNode Libraries Used:\n[archiver](https://github.com/ctalkington/node-archiver) (for zip/tar)\n[zlib](https://nodejs.org/api/zlib.html#zlib_options) (for gzip).\n### Options\n\n#### archive\nType: `String` or `Function`  \nModes: `zip` `tar`\n\nThis is used to define where to output the archive. Each target can only have one output file.\nIf the type is a Function it must return a String.\n\n*This option is only appropriate for many-files-to-one compression modes like zip and tar.  For gzip for example, please use grunt's standard src/dest specifications.*\n\n#### mode\nType: `String`\n\nThis is used to define which mode to use, currently supports `gzip`, `deflate`, `deflateRaw`, `tar`, `tgz` (tar gzip),`zip` and `brotli`.\n\nAutomatically detected per `dest:src` pair, but can be overridden per target if desired.\n\n#### level\nType: `Integer`  \nModes: `zip` `gzip`  \nDefault: `1`\n\nSets the level of archive compression.\n\n#### brotli\nConfigure brotli compression settings:\n\nType: `Object`  \nDefault:\n```js\n{\n    [zlib.constants.BROTLI_PARAM_MODE]: 0,\n    [zlib.constants.BROTLI_PARAM_QUALITY]: 11,\n    [zlib.constants.BROTLI_PARAM_LGWIN]: 22,\n    [zlib.constants.BROTLI_PARAM_LGBLOCK]: 0\n}\n```\n\nDo not forget require `zlib` for `zlib.constants`, example:\n```\nconst zlib = require('zlib');\n```\n\n##### mode\nType: `Integer`\n* `0`: generic mode\n* `1`: text mode\n* `2`: font mode\n\nDefault: `0`\n\n##### quality\nControls the compression-speed vs compression-density tradeoffs. The higher the quality, the slower the compression. Range is 0 to 11.\n\nType: `Integer`  \nDefault: `11`\n\n##### lgwin\nBase 2 logarithm of the sliding window size. Range is 10 to 24.\n\nType: `Integer`  \nDefault: `22`\n\n##### lgblock\nBase 2 logarithm of the maximum input block size. Range is 16 to 24. If set to 0, the value will be set based on the quality.  \n\nType: `Integer`  \nDefault: `0`\n\n#### pretty\nType: `Boolean`  \nDefault: `false`\n\nPretty print file sizes when logging.\n\n#### createEmptyArchive\nType: `Boolean`  \nDefault: `true`\n\nThis can be used when you don't want to get an empty archive as a result, if there are no files at the specified paths.\n\nIt may be useful, if you don't clearly know if files exist and you don't need an empty archive as a result.\n\n### File Data\n\nThe following additional keys may be passed as part of a `dest:src` pair when using an Archiver-backed format.\nAll keys can be defined as a `Function` that receives the file name and returns in the type specified below.\n\n#### date\nType: `Date`  \nModes: `zip` `tar` `tgz`\n\nSets the file date.\n\n#### mode\nType: `Integer`  \nModes: `zip` `tar` `tgz`\n\nSets the file permissions.\n\n#### store\nType: `Boolean`  \nDefault: `false`\n\nIf true, file contents will be archived without compression.\n\n#### comment\nType: `String`  \nModes: `zip`\n\nSets the file comment.\n\n#### gid\nType: `Integer`  \nModes: `tar` `tgz`\n\nSets the group of the file in the archive\n\n#### uid\nType: `Integer`  \nModes: `tar` `tgz`\n\nSets the user of the file in the archive\n\n### Usage Examples\n\n```js\n// make a zipfile\ncompress: {\n  main: {\n    options: {\n      archive: 'archive.zip'\n    },\n    files: [\n      {src: ['path/*'], dest: 'internal_folder/', filter: 'isFile'}, // includes files in path\n      {src: ['path/**'], dest: 'internal_folder2/'}, // includes files in path and its subdirs\n      {expand: true, cwd: 'path/', src: ['**'], dest: 'internal_folder3/'}, // makes all src relative to cwd\n      {flatten: true, src: ['path/**'], dest: 'internal_folder4/', filter: 'isFile'} // flattens results to a single level\n    ]\n  }\n}\n```\n\n```js\n// gzip assets 1-to-1 for production\ncompress: {\n  main: {\n    options: {\n      mode: 'gzip'\n    },\n    expand: true,\n    cwd: 'assets/',\n    src: ['**/*'],\n    dest: 'public/'\n  }\n}\n```\n\n```js\n// compress a file to a different location than its source\n// example compresses path/the_file to /the_file inside archive.zip\ncompress: {\n  main: {\n    options: {\n      archive: 'archive.zip'\n    },\n    files: [{\n      expand: true,\n      cwd: 'path/',\n      src: ['the_file'],\n      dest: '/'\n    }]\n  }\n},\n```\n\n```js\n// use custom extension for the output file\ncompress: {\n  main: {\n    options: {\n      mode: 'gzip'\n    },\n    // Each of the files in the src/ folder will be output to\n    // the dist/ folder each with the extension .gz.js\n    files: [{\n      expand: true,\n      src: ['src/*.js'],\n      dest: 'dist/',\n      ext: '.gz.js'\n    }]\n  }\n}\n\n```\n```js\n// use a function to return the output file\ncompress: {\n  main: {\n    options: {\n      archive: function () {\n        // The global value git.tag is set by another task\n        return git.tag + '.zip'\n      }\n    },\n    files: [{\n      expand: true,\n      src: ['src/*.js'],\n      dest: 'dist/'\n    }]\n  }\n}\n```\n\n```js\n// brotlify assets 1-to-1 for production using default options\ncompress: {\n  main: {\n    options: {\n      mode: 'brotli'\n    },\n    expand: true,\n    cwd: 'assets/',\n    src: ['**/*.js'],\n    dest: 'public/',\n    extDot: 'last',\n    ext: '.js.br'\n  }\n}\n```\n\n```js\n// brotlify assets 1-to-1 for production specifying text mode\n// and using default options otherwise\ncompress: {\n  main: {\n    options: {\n      mode: 'brotli',\n      brotli: {\n        mode: 1\n      }\n    },\n    expand: true,\n    cwd: 'assets/',\n    src: ['**/*.js'],\n    dest: 'public/',\n    extDot: 'last',\n    ext: '.js.br'\n  }\n}\n```\n\n\n## Release History\n\n * 2020-12-12   v2.0.0   Remove iltorb dependency, now uses zlib brotli features. Requires node \u003e=10.16. Dependency and test updates.\n * 2019-10-21   v1.6.0   Update iltorb dependency\n * 2018-04-24   v1.5.0   Update to node 4 as minimum version update tar to 4.4.8\n * 2017-05-20   v1.4.3   Update pretty-bytes to v4.0.2. Add option to not to create empty archive.\n * 2017-05-20   v1.4.2   Update archiver to v1.3.0.\n * 2017-01-20   v1.4.1   Make brotli support optional.\n * 2017-01-18   v1.4.0   Add support for brotli.\n * 2016-05-24   v1.3.0   Update archiver to v1.0. Fix node 6 support.\n * 2016-03-24   v1.2.0   Dependency update.\n * 2016-03-08   v1.1.1   Fix verbose output.\n * 2016-03-04   v1.1.0   Add ability to replace file in the same location.\n * 2016-02-15   v1.0.0   Update archiver, chalk and pretty-bytes.\n * 2015-10-23   v0.14.0   Change to verbose output. Dependency updates archiver 0.16.\n * 2014-12-25   v0.13.0   Update archiver to v0.13. Small fixes.\n * 2014-09-23   v0.12.0   Output update. Prevent zipping dot files and allow for forcing through `fail.warn` within loop.\n * 2014-08-26   v0.11.0   Update archiver to v0.11.0.\n * 2014-07-14   v0.10.0   Don't apply extensions automatically (use `ext` or `rename`).\n * 2014-05-20   v0.9.1   Allow directories to pass-through to archiver via filter.\n * 2014-05-20   v0.9.0   Update archiver to v0.9.0.\n * 2014-04-09   v0.8.0   Update archiver to v0.8.0.\n * 2014-02-17   v0.7.0   Update archiver to v0.6.0.\n * 2014-01-12   v0.6.0   Update archiver to v0.5.0.\n * 2013-11-27   v0.5.3   Allow archive option to be a function.\n * 2013-06-03   v0.5.2   Allow custom extensions using the `ext` option.\n * 2013-05-28   v0.5.1   Avoid gzip on folders.\n * 2013-04-23   v0.5.0   Add support for `deflate` and `deflateRaw`.\n * 2013-04-15   v0.4.10   Fix issue where task finished before all data was compressed.\n * 2013-04-09   v0.4.9   Bump Archiver version.\n * 2013-04-07   v0.4.8   Open streams lazily to avoid too many open files.\n * 2013-04-01   v0.4.7   Pipe gzip to fix gzip issues. Add tests that undo compressed files to test.\n * 2013-03-25   v0.4.6   Fix Node.js v0.8 compatibility issue with gzip.\n * 2013-03-20   v0.4.5   Update to archiver 0.4.1 Fix issue with gzip failing intermittently.\n * 2013-03-19   v0.4.4   Fixes for Node.js v0.10. Explicitly call `grunt.file` methods with `map` and `filter`.\n * 2013-03-14   v0.4.3   Fix for gzip; continue iteration on returning early.\n * 2013-03-13   v0.4.2   Refactor task like other contrib tasks. Fix gzip of multiple files. Remove unused dependencies.\n * 2013-02-22   v0.4.1   Pretty print compressed sizes. Logging each addition to a compressed file now only happens in verbose mode.\n * 2013-02-15   v0.4.0   First official release for Grunt 0.4.0.\n * 2013-01-23   v0.4.0rc7   Updating grunt/gruntplugin dependencies to rc7. Changing in-development grunt/gruntplugin dependency versions from tilde version ranges to specific versions.\n * 2013-01-14   v0.4.0rc5   Updating to work with grunt v0.4.0rc5. Conversion to grunt v0.4 conventions. Replace `basePath` with `cwd`.\n * 2012-10-12   v0.3.2   Rename grunt-contrib-lib dep to grunt-lib-contrib.\n * 2012-10-09   v0.3.1   Replace zipstream package with archiver.\n * 2012-09-24   v0.3.0   General cleanup. Options no longer accepted from global config key.\n * 2012-09-18   v0.2.2   Test refactoring. No valid source check. Automatic mode detection.\n * 2012-09-10   v0.2.0   Refactored from grunt-contrib into individual repo.\n\n---\n\nTask submitted by [Chris Talkington](http://christalkington.com/)\n\n*This file was generated on Sat Dec 12 2020 14:15:27.*\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgruntjs%2Fgrunt-contrib-compress","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgruntjs%2Fgrunt-contrib-compress","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgruntjs%2Fgrunt-contrib-compress/lists"}