Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
# cssnano-preset-default
> Safe defaults for cssnano which require minimal configuration.
## Table of Contents
- [Overview](#overview)
- [Usage](#usage)
- [Install](#install)
- [Configuration](#configuration)
- [Plugins](#plugins)
- [cssnano-util-raw-cache](#cssnano-util-raw-cache)
- [postcss-calc (external)](#postcss-calc-external)
- [postcss-colormin](#postcss-colormin)
- [postcss-convert-values](#postcss-convert-values)
- [postcss-discard-comments](#postcss-discard-comments)
- [postcss-discard-duplicates](#postcss-discard-duplicates)
- [postcss-discard-empty](#postcss-discard-empty)
- [postcss-discard-overridden](#postcss-discard-overridden)
- [postcss-merge-longhand](#postcss-merge-longhand)
- [postcss-merge-rules](#postcss-merge-rules)
- [postcss-minify-font-values](#postcss-minify-font-values)
- [postcss-minify-gradients](#postcss-minify-gradients)
- [postcss-minify-params](#postcss-minify-params)
- [postcss-minify-selectors](#postcss-minify-selectors)
- [postcss-normalize-charset](#postcss-normalize-charset)
- [postcss-normalize-display-values](#postcss-normalize-display-values)
- [postcss-normalize-positions](#postcss-normalize-positions)
- [postcss-normalize-repeat-style](#postcss-normalize-repeat-style)
- [postcss-normalize-string](#postcss-normalize-string)
- [postcss-normalize-timing-functions](#postcss-normalize-timing-functions)
- [postcss-normalize-unicode](#postcss-normalize-unicode)
- [postcss-normalize-url](#postcss-normalize-url)
- [postcss-normalize-whitespace](#postcss-normalize-whitespace)
- [postcss-ordered-values](#postcss-ordered-values)
- [postcss-reduce-initial](#postcss-reduce-initial)
- [postcss-reduce-transforms](#postcss-reduce-transforms)
- [postcss-svgo](#postcss-svgo)
- [postcss-unique-selectors](#postcss-unique-selectors)
- [Contributors](#contributors)
- [License](#license)
## Overview
This default preset for cssnano only includes transforms that make no
assumptions about your CSS other than what is passed in. In previous
iterations of cssnano, assumptions were made about your CSS which caused
output to look different in certain use cases, but not others. These
transforms have been moved from the defaults to other presets, to make
this preset require only minimal configuration.
## Usage
### Install
Note that this preset comes bundled with cssnano _by default_, so you don't need to install it separately.
### Configuration
If you would like to use the default configuration, then you don't need to add anything to your `package.json`.
But 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:
```diff
{
"name": "awesome-application",
+ "cssnano": {
+ "preset": [
+ "default",
+ {"discardComments": {"removeAll": true}}
+ ]
+ }
}
```
Depending 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:
```js
const defaultPreset = require('cssnano-preset-default');
module.exports = defaultPreset({
discardComments: {
remove: comment => comment[0] === "@"
}
});
```
Note 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!
## Plugins
### [`css-declaration-sorter`](https://github.com/Siilwyn/css-declaration-sorter) (external)
> Sorts CSS declarations fast and automatically in a certain order.
This plugin is loaded with its default configuration.
### [`cssnano-util-raw-cache`](https://github.com/cssnano/cssnano/tree/master/packages/cssnano-util-raw-cache)
> Manages the raw value formatting for generated AST nodes.
This plugin is loaded with its default configuration.
### [`postcss-calc`](https://github.com/postcss/postcss-calc) (external)
> PostCSS plugin to reduce calc()
This plugin is loaded with its default configuration.
### [`postcss-colormin`](https://github.com/cssnano/cssnano/tree/master/packages/postcss-colormin)
> Minify colors in your CSS files with PostCSS.
This plugin is loaded with its default configuration.
### [`postcss-convert-values`](https://github.com/cssnano/cssnano/tree/master/packages/postcss-convert-values)
> Convert values with PostCSS (e.g. ms -> s)
This plugin is loaded with the following configuration:
```js
{
length: false
}
```
### [`postcss-discard-comments`](https://github.com/cssnano/cssnano/tree/master/packages/postcss-discard-comments)
> Discard comments in your CSS files with PostCSS.
This plugin is loaded with its default configuration.
### [`postcss-discard-duplicates`](https://github.com/cssnano/cssnano/tree/master/packages/postcss-discard-duplicates)
> Discard duplicate rules in your CSS files with PostCSS.
This plugin is loaded with its default configuration.
### [`postcss-discard-empty`](https://github.com/cssnano/cssnano/tree/master/packages/postcss-discard-empty)
> Discard empty rules and values with PostCSS.
This plugin is loaded with its default configuration.
### [`postcss-discard-overridden`](https://github.com/cssnano/cssnano/tree/master/packages/postcss-discard-overridden)
> PostCSS plugin to discard overridden @keyframes or @counter-style.
This plugin is loaded with its default configuration.
### [`postcss-merge-longhand`](https://github.com/cssnano/cssnano/tree/master/packages/postcss-merge-longhand)
> Merge longhand properties into shorthand with PostCSS.
This plugin is loaded with its default configuration.
### [`postcss-merge-rules`](https://github.com/cssnano/cssnano/tree/master/packages/postcss-merge-rules)
> Merge CSS rules with PostCSS.
This plugin is loaded with its default configuration.
### [`postcss-minify-font-values`](https://github.com/cssnano/cssnano/tree/master/packages/postcss-minify-font-values)
> Minify font declarations with PostCSS
This plugin is loaded with its default configuration.
### [`postcss-minify-gradients`](https://github.com/cssnano/cssnano/tree/master/packages/postcss-minify-gradients)
> Minify gradient parameters with PostCSS.
This plugin is loaded with its default configuration.
### [`postcss-minify-params`](https://github.com/cssnano/cssnano/tree/master/packages/postcss-minify-params)
> Minify at-rule params with PostCSS
This plugin is loaded with its default configuration.
### [`postcss-minify-selectors`](https://github.com/cssnano/cssnano/tree/master/packages/postcss-minify-selectors)
> Minify selectors with PostCSS.
This plugin is loaded with its default configuration.
### [`postcss-normalize-charset`](https://github.com/cssnano/cssnano/tree/master/packages/postcss-normalize-charset)
> Add necessary or remove extra charset with PostCSS
This plugin is loaded with the following configuration:
```js
{
add: false
}
```
### [`postcss-normalize-display-values`](https://github.com/cssnano/cssnano/tree/master/packages/postcss-normalize-display-values)
> Normalize multiple value display syntaxes into single values.
This plugin is loaded with its default configuration.
### [`postcss-normalize-positions`](https://github.com/cssnano/cssnano/tree/master/packages/postcss-normalize-positions)
> Normalize keyword values for position into length values.
This plugin is loaded with its default configuration.
### [`postcss-normalize-repeat-style`](https://github.com/cssnano/cssnano/tree/master/packages/postcss-normalize-repeat-style)
> Convert two value syntax for repeat-style into one value.
This plugin is loaded with its default configuration.
### [`postcss-normalize-string`](https://github.com/cssnano/cssnano/tree/master/packages/postcss-normalize-string)
> Normalize wrapping quotes for CSS string literals.
This plugin is loaded with its default configuration.
### [`postcss-normalize-timing-functions`](https://github.com/cssnano/cssnano/tree/master/packages/postcss-normalize-timing-functions)
> Normalize CSS animation/transition timing functions.
This plugin is loaded with its default configuration.
### [`postcss-normalize-unicode`](https://github.com/cssnano/cssnano/tree/master/packages/postcss-normalize-unicode)
> Normalize unicode-range descriptors, and can convert to wildcard ranges.
This plugin is loaded with its default configuration.
### [`postcss-normalize-url`](https://github.com/cssnano/cssnano/tree/master/packages/postcss-normalize-url)
> Normalize URLs with PostCSS
This plugin is loaded with its default configuration.
### [`postcss-normalize-whitespace`](https://github.com/cssnano/cssnano/tree/master/packages/postcss-normalize-whitespace)
> Trim whitespace inside and around CSS rules & declarations.
This plugin is loaded with its default configuration.
### [`postcss-ordered-values`](https://github.com/cssnano/cssnano/tree/master/packages/postcss-ordered-values)
> Ensure values are ordered consistently in your CSS.
This plugin is loaded with its default configuration.
### [`postcss-reduce-initial`](https://github.com/cssnano/cssnano/tree/master/packages/postcss-reduce-initial)
> Reduce initial definitions to the actual initial value, where possible.
This plugin is loaded with its default configuration.
### [`postcss-reduce-transforms`](https://github.com/cssnano/cssnano/tree/master/packages/postcss-reduce-transforms)
> Reduce transform functions with PostCSS.
This plugin is loaded with its default configuration.
### [`postcss-svgo`](https://github.com/cssnano/cssnano/tree/master/packages/postcss-svgo)
> Optimise inline SVG with PostCSS.
This plugin is loaded with its default configuration.
### [`postcss-unique-selectors`](https://github.com/cssnano/cssnano/tree/master/packages/postcss-unique-selectors)
> Ensure CSS selectors are unique.
This plugin is loaded with its default configuration.
## Contributors
See [CONTRIBUTORS.md](https://github.com/cssnano/cssnano/blob/master/CONTRIBUTORS.md).
## License
MIT © [Ben Briggs](http://beneb.info)