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.

297 lines
10 KiB

4 years ago
  1. # cssnano-preset-default
  2. > Safe defaults for cssnano which require minimal configuration.
  3. ## Table of Contents
  4. - [Overview](#overview)
  5. - [Usage](#usage)
  6. - [Install](#install)
  7. - [Configuration](#configuration)
  8. - [Plugins](#plugins)
  9. - [cssnano-util-raw-cache](#cssnano-util-raw-cache)
  10. - [postcss-calc (external)](#postcss-calc-external)
  11. - [postcss-colormin](#postcss-colormin)
  12. - [postcss-convert-values](#postcss-convert-values)
  13. - [postcss-discard-comments](#postcss-discard-comments)
  14. - [postcss-discard-duplicates](#postcss-discard-duplicates)
  15. - [postcss-discard-empty](#postcss-discard-empty)
  16. - [postcss-discard-overridden](#postcss-discard-overridden)
  17. - [postcss-merge-longhand](#postcss-merge-longhand)
  18. - [postcss-merge-rules](#postcss-merge-rules)
  19. - [postcss-minify-font-values](#postcss-minify-font-values)
  20. - [postcss-minify-gradients](#postcss-minify-gradients)
  21. - [postcss-minify-params](#postcss-minify-params)
  22. - [postcss-minify-selectors](#postcss-minify-selectors)
  23. - [postcss-normalize-charset](#postcss-normalize-charset)
  24. - [postcss-normalize-display-values](#postcss-normalize-display-values)
  25. - [postcss-normalize-positions](#postcss-normalize-positions)
  26. - [postcss-normalize-repeat-style](#postcss-normalize-repeat-style)
  27. - [postcss-normalize-string](#postcss-normalize-string)
  28. - [postcss-normalize-timing-functions](#postcss-normalize-timing-functions)
  29. - [postcss-normalize-unicode](#postcss-normalize-unicode)
  30. - [postcss-normalize-url](#postcss-normalize-url)
  31. - [postcss-normalize-whitespace](#postcss-normalize-whitespace)
  32. - [postcss-ordered-values](#postcss-ordered-values)
  33. - [postcss-reduce-initial](#postcss-reduce-initial)
  34. - [postcss-reduce-transforms](#postcss-reduce-transforms)
  35. - [postcss-svgo](#postcss-svgo)
  36. - [postcss-unique-selectors](#postcss-unique-selectors)
  37. - [Contributors](#contributors)
  38. - [License](#license)
  39. ## Overview
  40. This default preset for cssnano only includes transforms that make no
  41. assumptions about your CSS other than what is passed in. In previous
  42. iterations of cssnano, assumptions were made about your CSS which caused
  43. output to look different in certain use cases, but not others. These
  44. transforms have been moved from the defaults to other presets, to make
  45. this preset require only minimal configuration.
  46. ## Usage
  47. ### Install
  48. Note that this preset comes bundled with cssnano _by default_, so you don't need to install it separately.
  49. ### Configuration
  50. If you would like to use the default configuration, then you don't need to add anything to your `package.json`.
  51. 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:
  52. ```diff
  53. {
  54. "name": "awesome-application",
  55. + "cssnano": {
  56. + "preset": [
  57. + "default",
  58. + {"discardComments": {"removeAll": true}}
  59. + ]
  60. + }
  61. }
  62. ```
  63. 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:
  64. ```js
  65. const defaultPreset = require('cssnano-preset-default');
  66. module.exports = defaultPreset({
  67. discardComments: {
  68. remove: comment => comment[0] === "@"
  69. }
  70. });
  71. ```
  72. 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!
  73. ## Plugins
  74. ### [`css-declaration-sorter`](https://github.com/Siilwyn/css-declaration-sorter) (external)
  75. > Sorts CSS declarations fast and automatically in a certain order.
  76. This plugin is loaded with its default configuration.
  77. ### [`cssnano-util-raw-cache`](https://github.com/cssnano/cssnano/tree/master/packages/cssnano-util-raw-cache)
  78. > Manages the raw value formatting for generated AST nodes.
  79. This plugin is loaded with its default configuration.
  80. ### [`postcss-calc`](https://github.com/postcss/postcss-calc) (external)
  81. > PostCSS plugin to reduce calc()
  82. This plugin is loaded with its default configuration.
  83. ### [`postcss-colormin`](https://github.com/cssnano/cssnano/tree/master/packages/postcss-colormin)
  84. > Minify colors in your CSS files with PostCSS.
  85. This plugin is loaded with its default configuration.
  86. ### [`postcss-convert-values`](https://github.com/cssnano/cssnano/tree/master/packages/postcss-convert-values)
  87. > Convert values with PostCSS (e.g. ms -> s)
  88. This plugin is loaded with the following configuration:
  89. ```js
  90. {
  91. length: false
  92. }
  93. ```
  94. ### [`postcss-discard-comments`](https://github.com/cssnano/cssnano/tree/master/packages/postcss-discard-comments)
  95. > Discard comments in your CSS files with PostCSS.
  96. This plugin is loaded with its default configuration.
  97. ### [`postcss-discard-duplicates`](https://github.com/cssnano/cssnano/tree/master/packages/postcss-discard-duplicates)
  98. > Discard duplicate rules in your CSS files with PostCSS.
  99. This plugin is loaded with its default configuration.
  100. ### [`postcss-discard-empty`](https://github.com/cssnano/cssnano/tree/master/packages/postcss-discard-empty)
  101. > Discard empty rules and values with PostCSS.
  102. This plugin is loaded with its default configuration.
  103. ### [`postcss-discard-overridden`](https://github.com/cssnano/cssnano/tree/master/packages/postcss-discard-overridden)
  104. > PostCSS plugin to discard overridden @keyframes or @counter-style.
  105. This plugin is loaded with its default configuration.
  106. ### [`postcss-merge-longhand`](https://github.com/cssnano/cssnano/tree/master/packages/postcss-merge-longhand)
  107. > Merge longhand properties into shorthand with PostCSS.
  108. This plugin is loaded with its default configuration.
  109. ### [`postcss-merge-rules`](https://github.com/cssnano/cssnano/tree/master/packages/postcss-merge-rules)
  110. > Merge CSS rules with PostCSS.
  111. This plugin is loaded with its default configuration.
  112. ### [`postcss-minify-font-values`](https://github.com/cssnano/cssnano/tree/master/packages/postcss-minify-font-values)
  113. > Minify font declarations with PostCSS
  114. This plugin is loaded with its default configuration.
  115. ### [`postcss-minify-gradients`](https://github.com/cssnano/cssnano/tree/master/packages/postcss-minify-gradients)
  116. > Minify gradient parameters with PostCSS.
  117. This plugin is loaded with its default configuration.
  118. ### [`postcss-minify-params`](https://github.com/cssnano/cssnano/tree/master/packages/postcss-minify-params)
  119. > Minify at-rule params with PostCSS
  120. This plugin is loaded with its default configuration.
  121. ### [`postcss-minify-selectors`](https://github.com/cssnano/cssnano/tree/master/packages/postcss-minify-selectors)
  122. > Minify selectors with PostCSS.
  123. This plugin is loaded with its default configuration.
  124. ### [`postcss-normalize-charset`](https://github.com/cssnano/cssnano/tree/master/packages/postcss-normalize-charset)
  125. > Add necessary or remove extra charset with PostCSS
  126. This plugin is loaded with the following configuration:
  127. ```js
  128. {
  129. add: false
  130. }
  131. ```
  132. ### [`postcss-normalize-display-values`](https://github.com/cssnano/cssnano/tree/master/packages/postcss-normalize-display-values)
  133. > Normalize multiple value display syntaxes into single values.
  134. This plugin is loaded with its default configuration.
  135. ### [`postcss-normalize-positions`](https://github.com/cssnano/cssnano/tree/master/packages/postcss-normalize-positions)
  136. > Normalize keyword values for position into length values.
  137. This plugin is loaded with its default configuration.
  138. ### [`postcss-normalize-repeat-style`](https://github.com/cssnano/cssnano/tree/master/packages/postcss-normalize-repeat-style)
  139. > Convert two value syntax for repeat-style into one value.
  140. This plugin is loaded with its default configuration.
  141. ### [`postcss-normalize-string`](https://github.com/cssnano/cssnano/tree/master/packages/postcss-normalize-string)
  142. > Normalize wrapping quotes for CSS string literals.
  143. This plugin is loaded with its default configuration.
  144. ### [`postcss-normalize-timing-functions`](https://github.com/cssnano/cssnano/tree/master/packages/postcss-normalize-timing-functions)
  145. > Normalize CSS animation/transition timing functions.
  146. This plugin is loaded with its default configuration.
  147. ### [`postcss-normalize-unicode`](https://github.com/cssnano/cssnano/tree/master/packages/postcss-normalize-unicode)
  148. > Normalize unicode-range descriptors, and can convert to wildcard ranges.
  149. This plugin is loaded with its default configuration.
  150. ### [`postcss-normalize-url`](https://github.com/cssnano/cssnano/tree/master/packages/postcss-normalize-url)
  151. > Normalize URLs with PostCSS
  152. This plugin is loaded with its default configuration.
  153. ### [`postcss-normalize-whitespace`](https://github.com/cssnano/cssnano/tree/master/packages/postcss-normalize-whitespace)
  154. > Trim whitespace inside and around CSS rules & declarations.
  155. This plugin is loaded with its default configuration.
  156. ### [`postcss-ordered-values`](https://github.com/cssnano/cssnano/tree/master/packages/postcss-ordered-values)
  157. > Ensure values are ordered consistently in your CSS.
  158. This plugin is loaded with its default configuration.
  159. ### [`postcss-reduce-initial`](https://github.com/cssnano/cssnano/tree/master/packages/postcss-reduce-initial)
  160. > Reduce initial definitions to the actual initial value, where possible.
  161. This plugin is loaded with its default configuration.
  162. ### [`postcss-reduce-transforms`](https://github.com/cssnano/cssnano/tree/master/packages/postcss-reduce-transforms)
  163. > Reduce transform functions with PostCSS.
  164. This plugin is loaded with its default configuration.
  165. ### [`postcss-svgo`](https://github.com/cssnano/cssnano/tree/master/packages/postcss-svgo)
  166. > Optimise inline SVG with PostCSS.
  167. This plugin is loaded with its default configuration.
  168. ### [`postcss-unique-selectors`](https://github.com/cssnano/cssnano/tree/master/packages/postcss-unique-selectors)
  169. > Ensure CSS selectors are unique.
  170. This plugin is loaded with its default configuration.
  171. ## Contributors
  172. See [CONTRIBUTORS.md](https://github.com/cssnano/cssnano/blob/master/CONTRIBUTORS.md).
  173. ## License
  174. MIT © [Ben Briggs](http://beneb.info)