| Number of watchers on Github | 91 |
| Number of open issues | 5 |
| Average time to close an issue | 6 days |
| Main language | JavaScript |
| Average time to merge a PR | about 2 hours |
| Open pull requests | 3+ |
| Closed pull requests | 8+ |
| Last commit | about 3 years ago |
| Repo Created | over 6 years ago |
| Repo Last Updated | almost 2 years ago |
| Size | 333 KB |
| Homepage | http://git.io/gru... |
| Organization / Author | mathiasbynens |
| Contributors | 7 |
| Page Updated | 2018-03-24 |
| Do you use grunt-zopfli? Leave a review! | |
| View open issues (5) | |
| View grunt-zopfli activity | |
| View on github | |
| Fresh, new opensource launches πππ | |
|
Trendy new open source projects in your inbox!
View examples
|
|
A Grunt plugin for compressing files using Zopfli.
This plugin requires Grunt v0.4.0+. Also, Zopfli must be installed.
First, you need a binary for your OS.
Installing Zopfli is easy with Homebrew just run the following command:
brew update; brew install zopfli
Compile the zopfli binary, then move it to any directory in our $PATH. Assuming /usr/local/bin is in your $PATH, you can just follow these steps:
cd /tmp
curl -LO 'https://github.com/google/zopfli/archive/zopfli-1.0.1.zip'
unzip zopfli-1.0.1.zip
cd zopfli-zopfli-1.0.1
make
chmod +x zopfli
cp zopfli /usr/local/bin
Heres an equivalent oneliner that can safely be copy-pasted:
cd /tmp; curl -LO 'https://github.com/google/zopfli/archive/zopfli-1.0.1.zip'; unzip zopfli-1.0.1.zip; cd zopfli-zopfli-1.0.1; make; chmod +x zopfli; cp zopfli /usr/local/bin
If you havent 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 youre familiar with that process, you may install this plugin with this command:
npm install grunt-zopfli --save-dev
One the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
grunt.loadNpmTasks('grunt-zopfli');
zopfli taskIn your projects Gruntfile, add a section named zopfli to the data object passed into grunt.initConfig().
grunt.initConfig({
'zopfli': {
'options': {
// Task-specific options go here
},
'your-target': {
'options': {
// Target-specific options go here
},
'files': {
// Target-specific file lists go here
},
'path': '' // Optional full path to `zopfli` binary; defaults to `zopfli` in `$PATH`
}
}
});
Note: Grunt offers several ways to define src dest (source destination) file mappings. This plugin supports all of them.
The options property can be used to override the following settings:
reportType: Boolean
Default: true
Show the original and compressed file size (true). Or not (false). Whatever.
iterationsType: Number
Default: 15
The number of iterations Zopfli will perform. Higher values result in better compression at the cost of speed.
formatType: String
Possible values: 'gzip', 'zlib', 'deflate'
Default: 'gzip'
The desired output format.
splitLastType: Boolean
Default: false
By default (false), Zopfli will perform block splitting first instead of last. Set to true to make Zopfli perform block splitting last instead of first.
Heres a practical example of grunt-zopfli with default settings:
grunt.initConfig({
'zopfli': {
'compress-plugins': {
'files': {
'dist/plugins.min.js.gz': 'dist/plugins.min.js'
}
}
}
});
Heres a slightly more advanced example:
grunt.initConfig({
'zopfli': {
'compress-plugins': {
'options': {
'report': false, // dont show original and compressed size (default: `true`)
'iterations': 50, // min value: `1`; (undocumented) max value: `99999999999` (default: `15`)
'format': 'zlib', // `'gzip'`, `'zlib'`, `'deflate'` (default: `'gzip'`)
'splitLast': true // perform block splitting first instead of last (default: `false`)
},
'files': {
'dist/plugins.min.js.gz': 'dist/plugins.min.js'
}
}
}
});
Or, to compress all files in input-directory, and save the compressed files to output-directory, using Grunts dynamic path expansion:
grunt.initConfig({
'zopfli': {
'compress': {
'options': {
'iterations': 20 // min value: `1`; (undocumented) max value: `99999999999` (default: `15`)
},
'files': {
'src': ['input-directory/*'],
'dest': 'output-directory/',
'expand': true,
'ext': '.js.gz'
}
}
}
});
| Mathias Bynens |
grunt-zopfli is dual licensed under the MIT and GPL licenses.