|
1 | | -grunt-css-purge |
| 1 | +<img alt="Grunt CSS Purge" src="https://raw.githubusercontent.com/rbtech/css-purge/master/assets/images/grunt-css-purge.png" width="133px"> |
| 2 | + |
| 3 | + |
| 4 | +Grunt CSS-PURGE |
2 | 5 | =============== |
3 | 6 |
|
4 | | -> Grunt plugin to run [CSS-Purge](https://github.com/rbtech/css-purge) |
| 7 | +Purges duplicate CSS rules and more. Based on [css-purge](https://www.npmjs.org/package/css-purge). |
5 | 8 |
|
6 | | -[](https://nodei.co/npm/grunt-css-purge/) |
7 | 9 |
|
8 | | -## Getting Started |
9 | | -This plugin requires Grunt. |
| 10 | +## You have an issue? |
| 11 | + |
| 12 | +This is a simple [grunt](http://gruntjs.com/) plugin, which means it’s a thin wrapper around `css-purge`. If you are having CSS issues, please |
| 13 | +contact [css-purge](https://github.com/rbtech/css-purge/issues). Please only create a new issue if it looks like you’re having a problem with the grunt plugin. |
10 | 14 |
|
11 | | -If you haven't used [Grunt](http://gruntjs.com/) before, be sure to check out the [Getting Started](http://gruntjs.com/getting-started) guide, |
12 | | -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 |
13 | | -with that process, you may install this plugin with this command: |
14 | 15 |
|
15 | | -```shell |
| 16 | +## Install |
| 17 | + |
| 18 | +``` |
16 | 19 | npm install grunt-css-purge --save-dev |
17 | 20 | ``` |
18 | 21 |
|
| 22 | + |
| 23 | +## Options |
| 24 | + |
| 25 | +Visit the [CSS-PURGE website](http://rbtech.github.io/css-purge) |
| 26 | + |
| 27 | + |
| 28 | +## Getting Started |
| 29 | + |
| 30 | +This plugin requires Grunt. |
| 31 | + |
| 32 | +If you haven’t used [Grunt](http://gruntjs.com/) before, be sure to check out the [Getting Started](http://gruntjs.com/getting-started) guide, |
| 33 | +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 |
| 34 | +with that process, you may install this plugin. |
19 | 35 | Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript: |
20 | 36 |
|
21 | 37 | ```js |
22 | 38 | grunt.loadNpmTasks('grunt-css-purge'); |
23 | 39 | ``` |
24 | 40 |
|
25 | | -## The "css_purge" task |
26 | 41 |
|
27 | | -### Overview |
28 | | -In your project's Gruntfile, add a section named `css_purge` to the data object passed into `grunt.initConfig()`. |
| 42 | +## Example use cases |
| 43 | + |
| 44 | +The most basic `Gruntfile.js` setup: |
29 | 45 |
|
30 | 46 | ```js |
31 | | -grunt.initConfig({ |
32 | | -css_purge: { |
33 | | -options: { |
34 | | -"verbose": false, |
35 | | -"no_duplicate_property": true, |
36 | | -}, |
37 | | -files: { |
38 | | -'purged.css': 'bigFile.css', |
| 47 | +'use strict'; |
| 48 | + |
| 49 | +module.exports = function( grunt ) { |
| 50 | +grunt.loadNpmTasks('grunt-css-purge'); |
| 51 | + |
| 52 | +grunt.initConfig({ |
| 53 | +css_purge: { |
| 54 | +site: { |
| 55 | +options: {}, |
| 56 | +src: 'site.css', |
| 57 | +dest: 'site.min.css', |
| 58 | +}, |
39 | 59 | }, |
40 | | -}, |
41 | | -}) |
| 60 | +}); |
| 61 | + |
| 62 | +grunt.registerTask('default', ['css_purge']); |
| 63 | +}; |
42 | 64 | ``` |
43 | 65 |
|
44 | | -### Options |
| 66 | +For more infos about the options please look at the [CSS-Purge website](http://rbtech.github.io/css-purge/). |
45 | 67 |
|
46 | | -#### options.verbose |
47 | | -Type: `Boolen` |
48 | | -Default value: `false` |
| 68 | +See below a couple different ways you can use the grunt task with various different files. |
49 | 69 |
|
50 | | -Show trace of optimization |
| 70 | +A single file: |
51 | 71 |
|
52 | | -#### options.no_duplicate_property |
53 | | -Type: `Boolen` |
54 | | -Default value: `true` |
| 72 | +```js |
| 73 | +default_options: { |
| 74 | +options: {}, |
| 75 | +src: 'site.css', |
| 76 | +dest: 'site.min.css', |
| 77 | +}, |
| 78 | +``` |
55 | 79 |
|
56 | | -Allow duplicate properties on a selector |
| 80 | +Multiple files: |
57 | 81 |
|
58 | | -### Usage Examples |
| 82 | +```js |
| 83 | +multiple_files: { |
| 84 | +options: {}, |
| 85 | +src: [ |
| 86 | +'site1.css', |
| 87 | +'site2.css', |
| 88 | +], |
| 89 | +dest: 'site.min.css', |
| 90 | +}, |
| 91 | +``` |
59 | 92 |
|
60 | | -#### Default Options |
| 93 | +Multiple files: |
61 | 94 |
|
62 | 95 | ```js |
63 | | -css_purge: { |
| 96 | +multiple_files2: { |
| 97 | +options: {}, |
64 | 98 | files: { |
65 | | -'purged.css': 'bigFile.css', |
| 99 | +'site.min.css': ['site1.css', 'site2.css'], |
66 | 100 | }, |
67 | 101 | }, |
68 | 102 | ``` |
69 | 103 |
|
70 | | -#### Custom Options |
| 104 | +Multiple files with a wildcard: |
71 | 105 |
|
72 | 106 | ```js |
73 | | -css_purge: { |
| 107 | +multiple_files3: { |
| 108 | +options: {}, |
| 109 | +files: [{ |
| 110 | +src: ['css/**/*.css'], |
| 111 | +dest: 'site.min.css', |
| 112 | +}], |
| 113 | +}, |
| 114 | +``` |
| 115 | + |
| 116 | +Custom options: |
| 117 | + |
| 118 | +```js |
| 119 | +custom_options: { |
74 | 120 | options: { |
75 | | -"verbose": false, |
76 | | -"no_duplicate_property": true, |
77 | | -}, |
78 | | -files: { |
79 | | -'purged.css': 'bigFile.css', |
| 121 | +trim_comments: false, |
| 122 | +generate_report: true, |
80 | 123 | }, |
| 124 | +src: 'site.css', |
| 125 | +dest: 'site.min.css', |
81 | 126 | }, |
82 | 127 | ``` |
83 | 128 |
|
| 129 | + |
84 | 130 | ## Contributing |
| 131 | + |
85 | 132 | In lieu of a formal styleguide, take care to maintain the existing coding style. |
86 | | -Add unit tests for any new or changed functionality. Lint and test your code using the [Grunt](http://gruntjs.com/) task already set up. |
| 133 | + |
87 | 134 |
|
88 | 135 | ## Release History |
| 136 | + |
| 137 | +* 1.0.0 - Updated to CSS-Purge 3.0.0 |
89 | 138 | * 0.0.4 - Updated peerDependencies for grunt 1.0 |
90 | 139 | * 0.0.3 - updated license |
91 | 140 | * 0.0.2 - refinements |
92 | 141 | * 0.0.1 - alpha test |
93 | 142 |
|
| 143 | + |
94 | 144 | ## License |
95 | | -Copyright (c) 2014 Dominik Wilkowski. Licensed under the GPLv2 license. |
| 145 | + |
| 146 | +Copyright (c) 2018 Dominik Wilkowski. Licensed under the GPLv2 license. |
0 commit comments