UNPKG

11.3 kBMarkdownView Raw
1# cssnano-preset-advanced
2
3> Advanced optimisations for cssnano; may or may not break your CSS!
4
5## Table of Contents
6
7- [Usage](#usage)
8
9 - [Install](#install)
10 - [Configuration](#configuration)
11
12- [Plugins](#plugins)
13
14 - [autoprefixer (external)](#autoprefixer-external)
15 - [css-declaration-sorter (external)](#css-declaration-sorter-external)
16 - [cssnano-utils](#cssnano-utils)
17 - [postcss-calc (external)](#postcss-calc-external)
18 - [postcss-colormin](#postcss-colormin)
19 - [postcss-convert-values](#postcss-convert-values)
20 - [postcss-discard-comments](#postcss-discard-comments)
21 - [postcss-discard-duplicates](#postcss-discard-duplicates)
22 - [postcss-discard-empty](#postcss-discard-empty)
23 - [postcss-discard-overridden](#postcss-discard-overridden)
24 - [postcss-discard-unused](#postcss-discard-unused)
25 - [postcss-merge-idents](#postcss-merge-idents)
26 - [postcss-merge-longhand](#postcss-merge-longhand)
27 - [postcss-merge-rules](#postcss-merge-rules)
28 - [postcss-minify-font-values](#postcss-minify-font-values)
29 - [postcss-minify-gradients](#postcss-minify-gradients)
30 - [postcss-minify-params](#postcss-minify-params)
31 - [postcss-minify-selectors](#postcss-minify-selectors)
32 - [postcss-normalize-charset](#postcss-normalize-charset)
33 - [postcss-normalize-display-values](#postcss-normalize-display-values)
34 - [postcss-normalize-positions](#postcss-normalize-positions)
35 - [postcss-normalize-repeat-style](#postcss-normalize-repeat-style)
36 - [postcss-normalize-string](#postcss-normalize-string)
37 - [postcss-normalize-timing-functions](#postcss-normalize-timing-functions)
38 - [postcss-normalize-unicode](#postcss-normalize-unicode)
39 - [postcss-normalize-url](#postcss-normalize-url)
40 - [postcss-normalize-whitespace](#postcss-normalize-whitespace)
41 - [postcss-ordered-values](#postcss-ordered-values)
42 - [postcss-reduce-idents](#postcss-reduce-idents)
43 - [postcss-reduce-initial](#postcss-reduce-initial)
44 - [postcss-reduce-transforms](#postcss-reduce-transforms)
45 - [postcss-svgo](#postcss-svgo)
46 - [postcss-unique-selectors](#postcss-unique-selectors)
47 - [postcss-zindex](#postcss-zindex)
48
49- [Contributors](#contributors)
50
51- [License](#license)
52
53## Usage
54
55### Install
56
57With [npm](https://npmjs.com/package/cssnano-preset-advanced) do:
58
59 npm install cssnano-preset-advanced --save-dev
60
61If you don't have npm then [check out this installation tutorial](https://npmjs.com/package/cssnano-preset-advanced/tutorial).
62
63### Configuration
64
65If you would like to use the preset in its default configuration, specify a section in your `package.json`:
66
67```diff
68 {
69 "name": "awesome-application",
70+ "cssnano": {
71+ "preset": "advanced"
72+ }
73 }
74```
75
76But should you wish to customise this, you can pass an array with the second parameter as the options object to use. For example, to remove all comments:
77
78```diff
79 {
80 "name": "awesome-application",
81+ "cssnano": {
82+ "preset": [
83+ "advanced",
84+ {"discardComments": {"removeAll": true}}
85+ ]
86+ }
87 }
88```
89
90Depending on your usage, the JSON configuration might not work for you, such as in cases where you would like to use options with customisable function parameters. For this use case, we recommend a `cssnano.config.js` at the same location as your `package.json`. You can then load a preset and export it with your custom parameters:
91
92```js
93const advancedPreset = require('cssnano-preset-advanced');
94
95module.exports = advancedPreset({
96 discardComments: {
97 remove: (comment) => comment[0] === '@',
98 },
99});
100```
101
102Note that you may wish to publish your own preset to npm for reusability, should it differ a lot from this one. This is highly encouraged!
103
104## Plugins
105
106### [`autoprefixer`](https://github.com/postcss/autoprefixer) (external)
107
108> Parse CSS and add vendor prefixes to CSS rules using values from the Can I Use website
109
110This plugin is loaded with the following configuration:
111
112```js
113{
114 add: false;
115}
116```
117
118### [`css-declaration-sorter`](https://github.com/Siilwyn/css-declaration-sorter) (external)
119
120> Sorts CSS declarations fast and automatically in a certain order.
121
122This plugin is loaded with the following configuration:
123
124```js
125{
126 exclude: true;
127}
128```
129
130### [`cssnano-utils`](https://github.com/cssnano/cssnano/tree/master/packages/cssnano-utils)
131
132> Utility methods used by cssnano
133
134### [`postcss-calc`](https://github.com/postcss/postcss-calc) (external)
135
136> PostCSS plugin to reduce calc()
137
138This plugin is loaded with its default configuration.
139
140### [`postcss-colormin`](https://github.com/cssnano/cssnano/tree/master/packages/postcss-colormin)
141
142> Minify colors in your CSS files with PostCSS.
143
144This plugin is loaded with its default configuration.
145
146### [`postcss-convert-values`](https://github.com/cssnano/cssnano/tree/master/packages/postcss-convert-values)
147
148> Convert values with PostCSS (e.g. ms -> s)
149
150This plugin is loaded with the following configuration:
151
152```js
153{
154 length: false;
155}
156```
157
158### [`postcss-discard-comments`](https://github.com/cssnano/cssnano/tree/master/packages/postcss-discard-comments)
159
160> Discard comments in your CSS files with PostCSS.
161
162This plugin is loaded with its default configuration.
163
164### [`postcss-discard-duplicates`](https://github.com/cssnano/cssnano/tree/master/packages/postcss-discard-duplicates)
165
166> Discard duplicate rules in your CSS files with PostCSS.
167
168This plugin is loaded with its default configuration.
169
170### [`postcss-discard-empty`](https://github.com/cssnano/cssnano/tree/master/packages/postcss-discard-empty)
171
172> Discard empty rules and values with PostCSS.
173
174This plugin is loaded with its default configuration.
175
176### [`postcss-discard-overridden`](https://github.com/cssnano/cssnano/tree/master/packages/postcss-discard-overridden)
177
178> PostCSS plugin to discard overridden @keyframes or @counter-style.
179
180This plugin is loaded with its default configuration.
181
182### [`postcss-discard-unused`](https://github.com/cssnano/cssnano/tree/master/packages/postcss-discard-unused)
183
184> Discard unused counter styles, keyframes and fonts.
185
186This plugin is loaded with its default configuration.
187
188### [`postcss-merge-idents`](https://github.com/cssnano/cssnano/tree/master/packages/postcss-merge-idents)
189
190> Merge keyframe and counter style identifiers.
191
192This plugin is loaded with its default configuration.
193
194### [`postcss-merge-longhand`](https://github.com/cssnano/cssnano/tree/master/packages/postcss-merge-longhand)
195
196> Merge longhand properties into shorthand with PostCSS.
197
198This plugin is loaded with its default configuration.
199
200### [`postcss-merge-rules`](https://github.com/cssnano/cssnano/tree/master/packages/postcss-merge-rules)
201
202> Merge CSS rules with PostCSS.
203
204This plugin is loaded with its default configuration.
205
206### [`postcss-minify-font-values`](https://github.com/cssnano/cssnano/tree/master/packages/postcss-minify-font-values)
207
208> Minify font declarations with PostCSS
209
210This plugin is loaded with its default configuration.
211
212### [`postcss-minify-gradients`](https://github.com/cssnano/cssnano/tree/master/packages/postcss-minify-gradients)
213
214> Minify gradient parameters with PostCSS.
215
216This plugin is loaded with its default configuration.
217
218### [`postcss-minify-params`](https://github.com/cssnano/cssnano/tree/master/packages/postcss-minify-params)
219
220> Minify at-rule params with PostCSS
221
222This plugin is loaded with its default configuration.
223
224### [`postcss-minify-selectors`](https://github.com/cssnano/cssnano/tree/master/packages/postcss-minify-selectors)
225
226> Minify selectors with PostCSS.
227
228This plugin is loaded with its default configuration.
229
230### [`postcss-normalize-charset`](https://github.com/cssnano/cssnano/tree/master/packages/postcss-normalize-charset)
231
232> Add necessary or remove extra charset with PostCSS
233
234This plugin is loaded with the following configuration:
235
236```js
237{
238 add: false;
239}
240```
241
242### [`postcss-normalize-display-values`](https://github.com/cssnano/cssnano/tree/master/packages/postcss-normalize-display-values)
243
244> Normalize multiple value display syntaxes into single values.
245
246This plugin is loaded with its default configuration.
247
248### [`postcss-normalize-positions`](https://github.com/cssnano/cssnano/tree/master/packages/postcss-normalize-positions)
249
250> Normalize keyword values for position into length values.
251
252This plugin is loaded with its default configuration.
253
254### [`postcss-normalize-repeat-style`](https://github.com/cssnano/cssnano/tree/master/packages/postcss-normalize-repeat-style)
255
256> Convert two value syntax for repeat-style into one value.
257
258This plugin is loaded with its default configuration.
259
260### [`postcss-normalize-string`](https://github.com/cssnano/cssnano/tree/master/packages/postcss-normalize-string)
261
262> Normalize wrapping quotes for CSS string literals.
263
264This plugin is loaded with its default configuration.
265
266### [`postcss-normalize-timing-functions`](https://github.com/cssnano/cssnano/tree/master/packages/postcss-normalize-timing-functions)
267
268> Normalize CSS animation/transition timing functions.
269
270This plugin is loaded with its default configuration.
271
272### [`postcss-normalize-unicode`](https://github.com/cssnano/cssnano/tree/master/packages/postcss-normalize-unicode)
273
274> Normalize unicode-range descriptors, and can convert to wildcard ranges.
275
276This plugin is loaded with its default configuration.
277
278### [`postcss-normalize-url`](https://github.com/cssnano/cssnano/tree/master/packages/postcss-normalize-url)
279
280> Normalize URLs with PostCSS
281
282This plugin is loaded with its default configuration.
283
284### [`postcss-normalize-whitespace`](https://github.com/cssnano/cssnano/tree/master/packages/postcss-normalize-whitespace)
285
286> Trim whitespace inside and around CSS rules & declarations.
287
288This plugin is loaded with its default configuration.
289
290### [`postcss-ordered-values`](https://github.com/cssnano/cssnano/tree/master/packages/postcss-ordered-values)
291
292> Ensure values are ordered consistently in your CSS.
293
294This plugin is loaded with its default configuration.
295
296### [`postcss-reduce-idents`](https://github.com/cssnano/cssnano/tree/master/packages/postcss-reduce-idents)
297
298> Reduce custom identifiers with PostCSS.
299
300This plugin is loaded with its default configuration.
301
302### [`postcss-reduce-initial`](https://github.com/cssnano/cssnano/tree/master/packages/postcss-reduce-initial)
303
304> Reduce initial definitions to the actual initial value, where possible.
305
306This plugin is loaded with its default configuration.
307
308### [`postcss-reduce-transforms`](https://github.com/cssnano/cssnano/tree/master/packages/postcss-reduce-transforms)
309
310> Reduce transform functions with PostCSS.
311
312This plugin is loaded with its default configuration.
313
314### [`postcss-svgo`](https://github.com/cssnano/cssnano/tree/master/packages/postcss-svgo)
315
316> Optimise inline SVG with PostCSS.
317
318This plugin is loaded with its default configuration.
319
320### [`postcss-unique-selectors`](https://github.com/cssnano/cssnano/tree/master/packages/postcss-unique-selectors)
321
322> Ensure CSS selectors are unique.
323
324This plugin is loaded with its default configuration.
325
326### [`postcss-zindex`](https://github.com/cssnano/cssnano/tree/master/packages/postcss-zindex)
327
328> Reduce z-index values with PostCSS.
329
330This plugin is loaded with its default configuration.
331
332## Contributors
333
334See [CONTRIBUTORS.md](https://github.com/cssnano/cssnano/blob/master/CONTRIBUTORS.md).
335
336## License
337
338MIT © [Ben Briggs](http://beneb.info)