You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

101 lines
3.6 KiB

  1. # grunt-contrib-cssmin [![Build Status](https://secure.travis-ci.org/gruntjs/grunt-contrib-cssmin.png?branch=master)](http://travis-ci.org/gruntjs/grunt-contrib-cssmin)
  2. > Compress CSS files.
  3. ## Getting Started
  4. This plugin requires Grunt `~0.4.0`
  5. If you haven't used [Grunt](http://gruntjs.com/) before, be sure to check out the [Getting Started](http://gruntjs.com/getting-started) guide, as it explains how to create a [Gruntfile](http://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:
  6. ```shell
  7. npm install grunt-contrib-cssmin --save-dev
  8. ```
  9. Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
  10. ```js
  11. grunt.loadNpmTasks('grunt-contrib-cssmin');
  12. ```
  13. *This plugin was designed to work with Grunt 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-cssmin/tree/grunt-0.3-stable).*
  14. ## Cssmin task
  15. _Run this task with the `grunt cssmin` command._
  16. Task targets, files and options may be specified according to the grunt [Configuring tasks](http://gruntjs.com/configuring-tasks) guide.
  17. Files are compressed with [clean-css](https://github.com/GoalSmashers/clean-css).
  18. ### Options
  19. #### banner
  20. Type: `String`
  21. Default: `null`
  22. Prefix the compressed source with the given banner, with a linebreak inbetween.
  23. #### keepSpecialComments
  24. Type: `String` `Number`
  25. Default: `'*'`
  26. To keep or remove special comments, exposing the underlying option from [clean-css](https://github.com/GoalSmashers/clean-css).. `'*'` for keeping all (default), `1` for keeping first one, `0` for removing all.
  27. #### report
  28. Choices: `false`, `'min'`, `'gzip'`
  29. Default: `false`
  30. Either do not report anything, report only minification result, or report minification and gzip results.
  31. This is useful to see exactly how well clean-css is performing but using `'gzip'` will make the task take 5-10x longer to complete.
  32. Example ouput using `'gzip'`:
  33. ```
  34. Original: 198444 bytes.
  35. Minified: 101615 bytes.
  36. Gzipped: 20084 bytes.
  37. ```
  38. ### Usage Examples
  39. ```js
  40. cssmin: {
  41. compress: {
  42. files: {
  43. 'path/to/output.css': ['path/to/input_one.css', 'path/to/input_two.css']
  44. }
  45. },
  46. with_banner: {
  47. options: {
  48. banner: '/* My minified css file */'
  49. },
  50. files: {
  51. 'path/to/output.css': ['path/to/**/*.css']
  52. }
  53. }
  54. }
  55. ```
  56. ## Release History
  57. * 2013-04-05   v0.6.0   Update clean-css dependency to ~1.0.0
  58. * 2013-03-14   v0.5.0   Support for 'report' option (false by default)
  59. * 2013-03-10   v0.4.2   Add banner option Support clean-css keepSpecialComments
  60. * 2013-02-17   v0.4.1   Update clean-css dependency to ~0.10.0
  61. * 2013-02-15   v0.4.0   First official release for Grunt 0.4.0.
  62. * 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.
  63. * 2013-01-09   v0.4.0rc5   Updating to work with grunt v0.4.0rc5. Switching to this.files api.
  64. * 2012-11-01   v0.3.2   Update clean-css dep.
  65. * 2012-10-12   v0.3.1   Rename grunt-contrib-lib dep to grunt-lib-contrib.
  66. * 2012-09-23   v0.3.0   Options no longer accepted from global config key.
  67. * 2012-09-10   v0.2.0   Refactored from grunt-contrib into individual repo.
  68. ---
  69. Task submitted by [Tim Branyen](http://goingslowly.com/)
  70. *This file was generated on Fri Apr 05 2013 09:03:50.*