postcss 5.0.10 → 5.0.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of postcss might be problematic. Click here for more details.

package/README.md CHANGED
@@ -4,22 +4,6 @@
4
4
  title="Philosopher’s stone, logo of PostCSS"
5
5
  src="http://postcss.github.io/postcss/logo.svg">
6
6
 
7
- PostCSS is a tool for transforming styles with JS plugins.
8
- These plugins can support variables and mixins, transpile future CSS syntax,
9
- inline images, and more.
10
-
11
- PostCSS is used by industry leaders including Google, Twitter, Alibaba,
12
- and Shopify. The [Autoprefixer] PostCSS plugin is one of the most popular
13
- CSS processors.
14
-
15
- PostCSS can do the same work as preprocessors like Sass, Less, and Stylus.
16
- But PostCSS is modular, 3-30 times faster, and much more powerful.
17
-
18
- Twitter account: [@postcss](https://twitter.com/postcss).
19
- VK.com page: [postcss](https://vk.com/postcss).
20
-
21
- Support / Discussion: [gitter](https://gitter.im/postcss/postcss).
22
-
23
7
  [appveyor-img]: https://img.shields.io/appveyor/ci/ai/postcss.svg?label=windows
24
8
  [travis-img]: https://img.shields.io/travis/postcss/postcss.svg?label=unix
25
9
  [chat-img]: https://img.shields.io/badge/Gitter-Join_the_PostCSS_chat-brightgreen.svg
@@ -27,750 +11,249 @@ Support / Discussion: [gitter](https://gitter.im/postcss/postcss).
27
11
  [travis]: https://travis-ci.org/postcss/postcss
28
12
  [chat]: https://gitter.im/postcss/postcss
29
13
 
30
- [Examples](#what-is-postcss) | [Features](#features) | [Usage](#usage) | [Syntaxes](#custom-syntaxes) | [Plugins](#plugins) | [Development](#how-to-develop-for-postcss) | [Options](#options)
31
- --- | --- | --- | --- | --- | --- | ---
14
+ PostCSS is a tool for transforming styles with JS plugins.
15
+ These plugins can lint your CSS, support variables and mixins,
16
+ transpile future CSS syntax, inline images, and more.
17
+
18
+ PostCSS is used by industry leaders including Google, Twitter, Alibaba,
19
+ and Shopify. The [Autoprefixer] PostCSS plugin is one of the most popular
20
+ CSS processors.
21
+
22
+ Twitter account: [@postcss](https://twitter.com/postcss).
23
+ VK.com page: [postcss](https://vk.com/postcss).
24
+ Support / Discussion: [Gitter](https://gitter.im/postcss/postcss).
25
+
26
+ [Autoprefixer]: https://github.com/postcss/autoprefixer
32
27
 
33
28
  <a href="https://evilmartians.com/?utm_source=postcss">
34
29
  <img src="https://evilmartians.com/badges/sponsored-by-evil-martians.svg" alt="Sponsored by Evil Martians" width="236" height="54">
35
30
  </a>
36
31
 
37
- [Autoprefixer]: https://github.com/postcss/autoprefixer
32
+ ## Plugins
38
33
 
39
- ## What is PostCSS
34
+ Currently, PostCSS has more than 200 plugins. Here are our favorite plugins
35
+ which best demonstrate PostCSS’ power. You can find all of the plugins in the
36
+ [plugins list] or in the [searchable catalog].
40
37
 
41
- PostCSS itself is very small. It includes only a CSS parser,
42
- a CSS node tree API, a source map generator, and a node tree stringifier.
38
+ If you have any new ideas, [PostCSS plugin development] is really easy.
43
39
 
44
- All of the style transformations are performed by plugins, which are
45
- plain JS functions. Each plugin receives a CSS node tree, transforms it & then
46
- returns the modified tree.
40
+ [searchable catalog]: http://postcss.parts
41
+ [plugins list]: https://github.com/postcss/postcss/blob/master/docs/plugins.md
47
42
 
48
- You can use the [cssnext] plugin pack and write future CSS code right now:
43
+ ### End of Global CSS
49
44
 
50
- ```css
51
- :root {
52
- --mainColor: #ffbbaaff;
53
- }
54
- @custom-media --mobile (width <= 640px);
55
- @custom-selector :--heading h1, h2, h3, h4, h5, h6;
45
+ * [`postcss-use`] to explicitly set PostCSS plugins in CSS and execute them
46
+ only for the current file.
47
+ * [`postcss-modules`] or [`react-css-modules`] automatically isolates
48
+ selectors in components.
49
+ * [`postcss-autoreset`] uses local reset in component, instead of global one.
50
+ * [`postcss-initial`] adds `all: initial` support to reset all inherit styles.
51
+ * [`cq-prolyfill`] adds media queries for component size
52
+ or parent background.
56
53
 
57
- .post-article :--heading {
58
- color: color( var(--mainColor) blackness(+20%) );
59
- }
60
- @media (--mobile) {
61
- .post-article :--heading {
62
- margin-top: 0;
63
- }
64
- }
65
- ```
54
+ ### Future CSS
66
55
 
67
- Or if you like the Sass syntax, you could use the [PreCSS] plugin pack:
56
+ * [`autoprefixer`] adds vendor prefixes, using data from Can I Use.
57
+ * [`cssnext`] allows you to use future CSS features today.
68
58
 
69
- ```css
70
- @define-mixin social-icon $network $color {
71
- &.is-$network {
72
- background: $color;
73
- }
74
- }
59
+ ### Syntax sugar
75
60
 
76
- .social-icon {
77
- @mixin social-icon twitter #55acee;
78
- @mixin social-icon facebook #3b5998;
61
+ * [`precss`] contains plugins for Sass-like features like nesting or mixins.
62
+ * [`short`] adds and extends numerous shorthand properties.
79
63
 
80
- padding: 10px 5px;
81
- @media (max-width: 640px) {
82
- padding: 0;
83
- }
84
- }
85
- ```
64
+ ### Images and Fonts
86
65
 
87
- [cssnext]: http://cssnext.io/
88
- [PreCSS]: https://github.com/jonathantneal/precss
66
+ * [`postcss-assets`] inserts image dimensions and inlines files.
67
+ * [`postcss-sprites`] generates image sprites.
68
+ * [`font-magician`] generates all the `@font-face` rules needed in CSS.
69
+ * [`postcss-inline-svg`] allows to inline SVG and customize its styles.
70
+ * [`postcss-write-svg`] allows to write simple SVG directly in CSS.
89
71
 
90
- ## Features
72
+ ### Linters
91
73
 
92
- Preprocessors are template languages, where you mix styles with code
93
- (like PHP does with HTML).
74
+ * [`stylelint`] is a modular linter for CSS.
75
+ * [`doiuse`] lints CSS for browser support, using data from Can I Use.
76
+ * [`colorguard`] helps maintain a consistent color palette.
94
77
 
95
- In contrast, in PostCSS you write a custom subset of CSS.
96
- All code can only be in JS plugins.
78
+ ### Other
97
79
 
98
- As a result, PostCSS offers three main benefits:
80
+ * [`lost`] is feature-rich `calc()` grid system by Jeet author.
81
+ * [`cssnano`] is a modular CSS minifier.
82
+ * [`rtlcss`] mirrors styles for right-to-left locales.
99
83
 
100
- * **Performance:** PostCSS, written in JS, is [2 times faster] than libsass,
101
- which is written in C++.
102
- * **Future CSS:** PostCSS plugins can read and rebuild an entire document,
103
- meaning that they can provide new language features. For example, [cssnext]
104
- transpiles the latest W3C drafts to current CSS syntax.
105
- * **New abilities:** PostCSS plugins can read and change every part of styles.
106
- It makes many new classes of tools possible. [Autoprefixer], [`rtlcss`],
107
- [`doiuse`] or [`postcss-colorblind`] are good examples.
84
+ [PostCSS plugin development]: https://github.com/postcss/postcss/blob/master/docs/writing-a-plugin.md
85
+ [`postcss-inline-svg`]: https://github.com/TrySound/postcss-inline-svg
86
+ [`react-css-modules`]: https://github.com/gajus/react-css-modules
87
+ [`postcss-autoreset`]: https://github.com/maximkoretskiy/postcss-autoreset
88
+ [`postcss-write-svg`]: https://github.com/jonathantneal/postcss-write-svg
89
+ [`postcss-initial`]: https://github.com/maximkoretskiy/postcss-initial
90
+ [`postcss-sprites`]: https://github.com/2createStudio/postcss-sprites
91
+ [`postcss-modules`]: https://github.com/outpunk/postcss-modules
92
+ [`postcss-assets`]: https://github.com/borodean/postcss-assets
93
+ [`font-magician`]: https://github.com/jonathantneal/postcss-font-magician
94
+ [`autoprefixer`]: https://github.com/postcss/autoprefixer
95
+ [`cq-prolyfill`]: https://github.com/ausi/cq-prolyfill
96
+ [`postcss-use`]: https://github.com/postcss/postcss-use
97
+ [`css-modules`]: https://github.com/css-modules/css-modules
98
+ [`colorguard`]: https://github.com/SlexAxton/css-colorguard
99
+ [`stylelint`]: https://github.com/stylelint/stylelint
100
+ [`cssnext`]: http://cssnext.io/
101
+ [`cssnano`]: http://cssnano.co/
102
+ [`precss`]: https://github.com/jonathantneal/precss
103
+ [`doiuse`]: https://github.com/anandthakker/doiuse
104
+ [`rtlcss`]: https://github.com/MohammadYounes/rtlcss
105
+ [`short`]: https://github.com/jonathantneal/postcss-short
106
+ [`lost`]: https://github.com/peterramsing/lost
107
+
108
+ ## Syntaxes
109
+
110
+ PostCSS can transform styles in any syntax, not just CSS.
108
111
 
109
- [2 times faster]: https://github.com/postcss/benchmark
112
+ * [`postcss-scss`] to work with SCSS *(but does not compile SCSS to CSS)*.
113
+ * [`postcss-js`] to write styles in JS or transform React Inline Styles,
114
+ Radium or JSS.
115
+ * [`postcss-safe-parser`] finds and fixes CSS syntax errors.
116
+ * [`midas`] converts a CSS string to highlighted HTML.
110
117
 
111
- ## Usage
118
+ [`postcss-safe-parser`]: https://github.com/postcss/postcss-safe-parser
119
+ [`postcss-scss`]: https://github.com/postcss/postcss-scss
120
+ [`postcss-js`]: https://github.com/postcss/postcss-js
121
+ [`midas`]: https://github.com/ben-eb/midas
112
122
 
113
- Start using PostCSS in just two steps:
123
+ ## Articles
114
124
 
115
- 1. Add PostCSS to your build tool.
116
- 2. Select plugins from the list below and add them to your PostCSS process.
125
+ * [Some things you may think about PostCSS and you might be wrong](http://julian.io/some-things-you-may-think-about-postcss-and-you-might-be-wrong/)
126
+ * [What PostCSS Really Is; What It Really Does](http://davidtheclark.com/its-time-for-everyone-to-learn-about-postcss/)
127
+ * [PostCSS Guides](http://webdesign.tutsplus.com/series/postcss-deep-dive--cms-889)
117
128
 
118
- There are plugins for [Grunt], [Gulp], [webpack], [Broccoli],
119
- [Brunch], [ENB], [Fly], [Stylus], [Duo] and [Connect/Express].
129
+ ## Usage
120
130
 
121
- ```js
122
- gulp.task('css', function () {
123
- var postcss = require('gulp-postcss');
124
- return gulp.src('src/**/*.css')
125
- .pipe( postcss([ require('autoprefixer'), require('cssnano') ]) )
126
- .pipe( gulp.dest('build/') );
127
- });
128
- ```
131
+ You can start using PostCSS in just two steps:
129
132
 
130
- To process CSS within the `<style>` tags and inline `style=` attributes
131
- in your HTML consider using [html-postcss] and [gulp-html-postcss].
133
+ 1. Find and add PostCSS extensions for your build tool.
134
+ 2. [Select plugins] and add them to your PostCSS process.
132
135
 
133
- For other environments, you can use the [CLI tool] or the JS API:
136
+ [Select plugins]: http://postcss.parts
134
137
 
135
- ```js
136
- var postcss = require('postcss');
137
- postcss([ require('autoprefixer'), require('cssnano') ])
138
- .process(css, { from: 'src/app.css', to: 'app.css' })
139
- .then(function (result) {
140
- fs.writeFileSync('app.css', result.css);
141
- if ( result.map ) fs.writeFileSync('app.css.map', result.map);
142
- });
143
- ```
138
+ ### Gulp
144
139
 
145
- If you want to run PostCSS on node.js 0.10, add [Promise polyfill]:
140
+ Use [`gulp-postcss`] and [`gulp-sourcemaps`].
146
141
 
147
142
  ```js
148
- require('es6-promise').polyfill();
149
- var postcss = require('postcss');
150
- ```
151
-
152
- Read the [PostCSS API] for more details about the JS API.
153
-
154
- [Promise polyfill]: https://github.com/jakearchibald/es6-promise
155
- [Connect/Express]: https://github.com/jedmao/postcss-middleware
156
- [PostCSS API]: https://github.com/postcss/postcss/blob/master/docs/api.md
157
- [Broccoli]: https://github.com/jeffjewiss/broccoli-postcss
158
- [CLI tool]: https://github.com/code42day/postcss-cli
159
- [webpack]: https://github.com/postcss/postcss-loader
160
- [Brunch]: https://github.com/iamvdo/postcss-brunch
161
- [Stylus]: https://github.com/seaneking/poststylus
162
- [Grunt]: https://github.com/nDmitry/grunt-postcss
163
- [Gulp]: https://github.com/postcss/gulp-postcss
164
- [ENB]: https://github.com/theprotein/enb-postcss
165
- [Fly]: https://github.com/postcss/fly-postcss
166
- [Duo]: https://github.com/duojs/duo
167
- [html-postcss]: https://github.com/RebelMail/html-postcss
168
- [gulp-html-postcss]:https://github.com/StartPolymer/gulp-html-postcss
169
-
170
- ## Custom Syntaxes
171
-
172
- PostCSS can transform styles in any syntax, not only in CSS.
173
- There are 3 special arguments in `process()` method to control syntax.
174
- You can even separately set input parser and output stringifier.
175
-
176
- * `syntax` accepts object with `parse` and `stringify` functions.
177
- * `parser` accepts input parser function.
178
- * `stringifier` accepts output stringifier function.
143
+ gulp.task('css', function () {
144
+ var postcss = require('gulp-postcss');
145
+ var sourcemaps = require('gulp-sourcemaps');
179
146
 
180
- ```js
181
- var safe = require('postcss-safe-parser');
182
- postcss(plugins).process('a {', { parser: safe }).then(function (result) {
183
- result.css //=> 'a {}'
147
+ return gulp.src('src/**/*.css')
148
+ .pipe( sourcemaps.init() )
149
+ .pipe( postcss([ require('autoprefixer'), require('precss') ]) )
150
+ .pipe( sourcemaps.write('.') )
151
+ .pipe( gulp.dest('build/') );
184
152
  });
185
153
  ```
186
154
 
187
- ### Syntaxes
155
+ [`gulp-sourcemaps`]: https://github.com/floridoo/gulp-sourcemaps
156
+ [`gulp-postcss`]: https://github.com/postcss/gulp-postcss
188
157
 
189
- * [`postcss-scss`] to work with SCSS *(but does not compile SCSS to CSS)*.
158
+ ### Webpack
190
159
 
191
- [`postcss-scss`]: https://github.com/postcss/postcss-scss
160
+ Use [`postcss-loader`]:
192
161
 
193
- ### Parsers
194
-
195
- * [`postcss-safe-parser`] finds and fix CSS syntax errors.
196
-
197
- [`postcss-safe-parser`]: https://github.com/postcss/postcss-safe-parser
198
-
199
- ### Stringifiers
200
-
201
- * [`midas`] converts a CSS string to highlighted HTML.
202
-
203
- [`midas`]: https://github.com/ben-eb/midas
204
-
205
- ## Plugins
206
-
207
- Go to [postcss.parts] for a searchable catalog of the plugins mentioned below.
208
-
209
- [postcss.parts]: http://postcss.parts
210
-
211
- ### Control
212
-
213
- There are two ways to make PostCSS magic more explicit.
214
-
215
- Limit a plugin's local stylesheet context using [`postcss-plugin-context`]:
216
-
217
- ```css
218
- .css-example.is-test-for-css4-browsers {
219
- color: gray(255, 50%);
220
- }
221
- @context cssnext {
222
- .css-example.is-fallback-for-all-browsers {
223
- color: gray(255, 50%);
162
+ ```js
163
+ module.exports = {
164
+ module: {
165
+ loaders: [
166
+ {
167
+ test: /\.css$/,
168
+ loader: "style-loader!css-loader!postcss-loader"
169
+ }
170
+ ]
171
+ },
172
+ postcss: function () {
173
+ return [require('autoprefixer'), require('precss')];
224
174
  }
225
175
  }
226
176
  ```
227
177
 
228
- Or enable plugins directly in CSS using [`postcss-use`]:
229
-
230
- ```css
231
- @use autoprefixer(browsers: ['last 2 versions']);
178
+ [`postcss-loader`]: https://github.com/postcss/postcss-loader
232
179
 
233
- :fullscreen a {
234
- display: flex
235
- }
236
- ```
180
+ ### CSS-in-JS
237
181
 
238
- [`postcss-plugin-context`]: https://github.com/postcss/postcss-plugin-context
239
- [`postcss-use`]: https://github.com/postcss/postcss-use
182
+ For React Inline Styles, JSS, Radium and other CSS-in-JS you can use
183
+ [`postcss-js`] to transform one style object to other.
240
184
 
241
- ### Packs
242
-
243
- * [`atcss`] contains plugins that transform your CSS according
244
- to special annotation comments.
245
- * [`cssnano`] contains plugins that optimize CSS size for use in production.
246
- * [`cssnext`] contains plugins that allow you to use future CSS features today.
247
- * [`oldie`] contains plugins that transform your CSS for older Internet Explorer compatibility.
248
- * [`precss`] contains plugins that allow you to use Sass-like CSS.
249
- * [`rucksack`] contains plugins to speed up CSS development
250
- with new features and shortcuts.
251
- * [`short`] adds and extends numerous shorthand properties.
252
- * [`stylelint`] contains plugins that lint your stylesheets.
253
-
254
- [`stylelint`]: https://github.com/stylelint/stylelint
255
- [`rucksack`]: http://simplaio.github.io/rucksack
256
- [`cssnano`]: http://cssnano.co/
257
- [`cssnext`]: http://cssnext.io/
258
- [`oldie`]: https://github.com/jonathantneal/oldie
259
- [`precss`]: https://github.com/jonathantneal/precss
260
- [`atcss`]: https://github.com/morishitter/atcss
261
-
262
- ### Future CSS Syntax
263
-
264
- * [`postcss-color-function`] supports functions to transform colors.
265
- * [`postcss-color-gray`] supports the `gray()` function.
266
- * [`postcss-color-hex-alpha`] supports `#rrggbbaa` and `#rgba` notation.
267
- * [`postcss-color-hwb`] transforms `hwb()` to widely compatible `rgb()`.
268
- * [`postcss-color-rebeccapurple`] supports the `rebeccapurple` color.
269
- * [`postcss-conic-gradient`] supports the `conic-gradient` background.
270
- * [`postcss-custom-media`] supports custom aliases for media queries.
271
- * [`postcss-custom-properties`] supports variables, using syntax from
272
- the W3C Custom Properties.
273
- * [`postcss-custom-selectors`] adds custom aliases for selectors.
274
- * [`postcss-extend`] supports spec-approximate `@extend` for rules
275
- and placeholders, recursively.
276
- * [`postcss-font-variant`] transpiles human-readable `font-variant`
277
- to more widely supported CSS.
278
- * [`postcss-host`] makes the Shadow DOM’s `:host` selector work properly
279
- with pseudo-classes.
280
- * [`postcss-initial`] supports `initial` keyword and `all: initial` to clean inherit styles.
281
- * [`postcss-media-minmax`] adds `<=` and `=>` statements to media queries.
282
- * [`postcss-pseudo-class-any-link`] adds `:any-link` pseudo-class.
283
- * [`postcss-selector-not`] transforms CSS4 `:not()` to CSS3 `:not()`.
284
- * [`postcss-selector-matches`] transforms CSS4 `:matches()` to more compatible CSS.
285
- * [`postcss-apply`] supports custom properties sets references
286
- * [`mq4-hover-shim`] supports the `@media (hover)` feature.
287
-
288
- See also [`cssnext`] plugins pack to add future CSS syntax by one line of code.
289
-
290
- ### Fallbacks
291
-
292
- * [`postcss-color-rgba-fallback`] transforms `rgba()` to hexadecimal.
293
- * [`postcss-epub`] adds the `-epub-` prefix to relevant properties.
294
- * [`postcss-mqwidth-to-class`] converts min/max-width media queries to classes.
295
- * [`postcss-opacity`] adds opacity filter for IE8.
296
- * [`postcss-pseudoelements`] Convert `::` selectors into `:` selectors
297
- for IE 8 compatibility.
298
- * [`postcss-unmq`] removes media queries while preserving desktop rules for IE≤8.
299
- * [`postcss-vmin`] generates `vm` fallback for `vmin` unit in IE9.
300
- * [`postcss-will-change`] inserts 3D hack before `will-change` property.
301
- * [`autoprefixer`] adds vendor prefixes for you, using data from Can I Use.
302
- * [`cssgrace`] provides various helpers and transpiles CSS 3 for IE
303
- and other old browsers.
304
- * [`pixrem`] generates pixel fallbacks for `rem` units.
305
- * [`postcss-round-subpixels`] plugin that rounds sub-pixel values to the nearest full pixel.
306
-
307
- ### Language Extensions
308
-
309
- * [`postcss-atroot`] place rules directly at the root node.
310
- * [`postcss-bem`] adds at-rules for BEM and SUIT style classes.
311
- * [`postcss-conditionals`] adds `@if` statements.
312
- * [`postcss-css-variables`] supports variables for selectors, and at-rules
313
- using W3C similar syntax.
314
- * [`postcss-define-property`] to define properties shortcut.
315
- * [`postcss-each`] adds `@each` statement.
316
- * [`postcss-for`] adds `@for` loops.
317
- * [`postcss-at-rules-variables`] adds support for custom properties in at-rules
318
- `@for`, `@each`, `@if` and more.
319
- * [`postcss-functions`] enables exposure of JavaScript functions.
320
- * [`postcss-local-constants`] adds support for localized constants.
321
- * [`postcss-map`] enables configuration maps.
322
- * [`postcss-match`] adds `@match` for [Rust-style pattern matching].
323
- * [`postcss-mixins`] enables mixins more powerful than Sass’,
324
- defined within stylesheets or in JS.
325
- * [`postcss-media-variables`] adds support for `var()` and `calc()`
326
- in `@media` rules
327
- * [`postcss-modular-scale`] adds a modular scale `ms()` function.
328
- * [`postcss-nested`] unwraps nested rules.
329
- * [`postcss-nested-props`] unwraps nested properties.
330
- * [`postcss-nested-vars`] supports nested Sass-style variables.
331
- * [`postcss-pseudo-class-enter`] transforms `:enter` into `:hover` and `:focus`.
332
- * [`postcss-quantity-queries`] enables quantity queries.
333
- * [`postcss-reverse-media`] reverse/Invert media query parameters.
334
- * [`postcss-sassy-mixins`] enables mixins with Sass keywords.
335
- * [`postcss-simple-extend`] lightweight extending of silent classes,
336
- like Sass’ `@extend`.
337
- * [`postcss-simple-vars`] supports for Sass-style variables.
338
- * [`postcss-strip-units`] strips units off of property values.
339
- * [`postcss-vertical-rhythm`] adds a vertical rhythm unit
340
- based on `font-size` and `line-height`.
341
- * [`csstyle`] adds components workflow to your styles.
342
-
343
- See also [`precss`] plugins pack to add them by one line of code.
344
-
345
- [Rust-style pattern matching]: https://doc.rust-lang.org/book/match.html
346
-
347
- ### Colors
348
-
349
- * [`postcss-ase-colors`] replaces color names with values read from an ASE palette file.
350
- * [`postcss-brand-colors`] inserts company brand colors
351
- in the `brand-colors` module.
352
- * [`postcss-color-alpha`] transforms `#hex.a`, `black(alpha)` and `white(alpha)`
353
- to `rgba()`.
354
- * [`postcss-color-hcl`] transforms `hcl(H, C, L)` and `hcl(H, C, L, alpha)`
355
- to `#rgb` and `rgba()`.
356
- * [`postcss-color-hexa`] transforms `hexa(hex, alpha)` into `rgba` format.
357
- * [`postcss-color-mix`] mixes two colors together.
358
- * [`postcss-color-palette`] transforms CSS 2 color keywords to a custom palette.
359
- * [`postcss-color-pantone`] transforms pantone color to RGB.
360
- * [`postcss-color-scale`] adds a color scale `cs()` function.
361
- * [`postcss-color-short`] adds shorthand color declarations.
362
- * [`postcss-color-yiq`] sets foreground colors using the YIQ color space.
363
- * [`postcss-colorblind`] transforms colors using filters to simulate
364
- colorblindness.
365
- * [`postcss-hexrgba`] adds shorthand hex `rgba(hex, alpha)` method.
366
- * [`postcss-rgb-plz`] converts 3 or 6 digit hex values to `rgb`.
367
- * [`colorguard`] helps maintain a consistent color palette.
185
+ ```js
186
+ var postcss = require('postcss-js');
187
+ var prefixer = postcss.sync([ require('autoprefixer') ]);
368
188
 
369
- ### Images and Fonts
189
+ prefixer({ display: 'flex' }); //=> { display: ['-webkit-box', '-webkit-flex', '-ms-flexbox', 'flex'] }
190
+ ```
370
191
 
371
- * [`postcss-assets`] allows you to simplify URLs, insert image dimensions,
372
- and inline files.
373
- * [`postcss-at2x`] handles retina background images via use of `at-2x` keyword.
374
- * [`postcss-copy-assets`] copies assets referenced by relative `url()`s into a
375
- build directory.
376
- * [`postcss-data-packer`] moves embedded Base64 data to a separate file.
377
- * [`postcss-image-set`] adds `background-image` with first image
378
- for `image-set()`.
379
- * [`postcss-image-inliner`] inlines local and remote images.
380
- * [`postcss-instagram`] adds Instagram filters to `filter`.
381
- * [`postcss-font-pack`] simplifies font declarations and validates they match
382
- configured font packs.
383
- * [`postcss-fontpath`] adds font links for different browsers.
384
- * [`postcss-responsive-images`] adds stylesheets for making your images responsive
385
- * [`postcss-sprites`] generates CSS sprites from stylesheets.
386
- * [`postcss-svg`] insert inline SVG to CSS and allows to manage it colors.
387
- * [`postcss-svg-fallback`] converts SVG in your CSS to PNG files for IE 8.
388
- * [`postcss-svgo`] processes inline SVG through [SVGO].
389
- * [`postcss-url`] rebases or inlines `url()`s.
390
- * [`postcss-urlrev`] adds MD5 hash strings to `url()`s.
391
- * [`postcss-write-svg`] write inline SVGs in CSS.
392
- * [`webpcss`] adds URLs for WebP images for browsers that support WebP.
393
-
394
- ### Grids
395
-
396
- * [`postcss-grid`] adds a semantic grid system.
397
- * [`postcss-simple-grid`] create grid with one line.
398
- * [`postcss-neat`] is a semantic and fluid grid framework.
399
- * [`lost`] feature-rich `calc()` grid system by Jeet author.
400
-
401
-
402
- ### Optimizations
403
-
404
- * [`postcss-calc`] reduces `calc()` to values
405
- (when expressions involve the same units).
406
- * [`postcss-import`] inlines the stylesheets referred to by `@import` rules.
407
- * [`postcss-partial-import`] inlines standard imports and Sass-like partials.
408
- * [`postcss-single-charset`] ensures that there is one and only one
409
- `@charset` rule at the top of file.
410
- * [`postcss-zindex`] rebases positive `z-index` values.
411
- * [`css-byebye`] removes the CSS rules that you don’t want.
412
- * [`css-mqpacker`] joins matching CSS media queries into a single statement.
413
- * [`stylehacks`] removes CSS hacks based on browser support.
414
-
415
- See also plugins in modular minifier [`cssnano`].
416
-
417
- [SVGO]: https://github.com/svg/svgo
418
-
419
- ### Shortcuts
420
-
421
- * [`postcss-alias`] creates shorter aliases for properties.
422
- * [`postcss-alias-atrules`] creates shorter aliases for at-rules.
423
- * [`postcss-all-link-colors`] insert colors for link-related pseudo-classes.
424
- * [`postcss-border`] adds shorthand for width and color of all borders
425
- in `border` property.
426
- * [`postcss-center`] centers elements.
427
- * [`postcss-circle`] inserts a circle with color.
428
- * [`postcss-clearfix`] adds `fix` and `fix-legacy` properties to the `clear`
429
- declaration.
430
- * [`postcss-crip`] shorthand properties for Crips that are too lazy to write.
431
- * [`postcss-default-unit`] adds default unit to numeric CSS properties.
432
- * [`postcss-easings`] replaces easing names from easings.net
433
- with `cubic-bezier()` functions.
434
- * [`postcss-filter`] adds shorthand for black and white filter.
435
- * [`postcss-focus`] adds `:focus` selector to every `:hover`.
436
- * [`postcss-generate-preset`] allows quick generation of rules.
437
- Useful for creating repetitive utilities.
438
- * [`postcss-input-style`] adds new pseudo-elements for cross-browser styling of inputs.
439
- * [`postcss-position`] adds shorthand declarations for position attributes.
440
- * [`postcss-property-lookup`] allows referencing property values without
441
- a variable.
442
- * [`postcss-responsive-type`] changes `font-size` depends on screen size.
443
- * [`postcss-short-font-size`] extends `font-size` to define line-height as a second value.
444
- * [`postcss-short-position`] extends `position` to define edges as additional values.
445
- * [`postcss-short-spacing`] extends `margin` and `padding` to allow for omitted edges.
446
- * [`postcss-short-text`] adds a `text` shortcut property for several text-related properties.
447
- * [`postcss-size`] adds a `size` shortcut that sets width and height
448
- with one declaration.
449
- * [`postcss-transform-shortcut`] allows shorthand transform properties in CSS.
450
- * [`postcss-triangle`] creates a triangle.
451
- * [`postcss-verthorz`] adds vertical and horizontal spacing declarations.
452
- * [`font-magician`] generates all the `@font-face` rules needed in CSS.
192
+ [`postcss-js`]: https://github.com/postcss/postcss-js
453
193
 
454
- ### Others
455
-
456
- * [`postcss-autoreset`] automatically adds reset styles.
457
- * [`postcss-class-prefix`] adds a prefix/namespace to class selectors.
458
- * [`postcss-currency`] replaces name of currency with symbols.
459
- * [`postcss-fakeid`] transforms `#foo` IDs to attribute selectors `[id="foo"]`.
460
- * [`postcss-flexboxfixer`] unprefixes `-webkit-` only flexbox in legacy CSS.
461
- * [`postcss-flexbugs-fixes`] fixes some of known [flexbox bugs].
462
- * [`postcss-gradientfixer`] unprefixes `-webkit-` only gradients in legacy CSS.
463
- * [`postcss-increase-specificity`] increases the specificity of your selectors.
464
- * [`postcss-mq-keyframes`] moves any animation keyframes in media queries
465
- to the end of the file.
466
- * [`postcss-pseudo-elements-content`] adds `content: ''` to `:before-c`
467
- and `:after-c`.
468
- * [`postcss-pseudo-content-insert`] adds `content: ''` to `:before` and `:after`
469
- if it is missing.
470
- * [`postcss-pxtorem`] converts pixel units to `rem`.
471
- * [`postcss-shorthand-expand`] expands shorthand properties.
472
- * [`postcss-remove-prefixes`] removes vendor prefixes.
473
- * [`postcss-style-guide`] generates a style guide automatically.
474
- * [`postcss-scopify`] adds a user input scope to each selector.
475
- * [`cssfmt`] formats CSS source code automatically inspired by Gofmt.
476
- * [`perfectionist`] formats poorly written CSS and renders a “pretty” result.
477
- * [`rtlcss`] mirrors styles for right-to-left locales.
194
+ ### Runners
478
195
 
479
- [flexbox bugs]: https://github.com/philipwalton/flexbugs
196
+ * **CLI**: [`postcss-cli`](https://github.com/code42day/postcss-cli)
197
+ * **Grunt**: [`grunt-postcss`](https://github.com/nDmitry/grunt-postcss)
198
+ * **HTML**: [`posthtml-postcss`](https://github.com/posthtml/posthtml-postcss)
199
+ * **Stylus**: [`poststylus`](https://github.com/seaneking/poststylus)
200
+ * **Rollup**: [`rollup-plugin-postcss`](https://github.com/egoist/rollup-plugin-postcss)
201
+ * **Brunch**: [`postcss-brunch`](https://github.com/iamvdo/postcss-brunch)
202
+ * **Broccoli**: [`broccoli-postcss`](https://github.com/jeffjewiss/broccoli-postcss)
203
+ * **Meteor**: [`postcss`](https://atmospherejs.com/juliancwirko/postcss)
204
+ * **ENB**: [`enb-postcss`](https://github.com/awinogradov/enb-postcss)
205
+ * **Fly**: [`fly-postcss`](https://github.com/postcss/fly-postcss)
206
+ * **Connect/Express**: [`postcss-middleware`](https://github.com/jedmao/postcss-middleware)
480
207
 
481
- ### Analysis
208
+ ### JS API
482
209
 
483
- * [`postcss-bem-linter`] lints CSS for conformance to SUIT CSS methodology.
484
- * [`postcss-cssstats`] returns an object with CSS statistics.
485
- * [`css2modernizr`] creates a Modernizr config file
486
- that requires only the tests that your CSS uses.
487
- * [`doiuse`] lints CSS for browser support, using data from Can I Use.
488
- * [`immutable-css`] lints CSS for class mutations.
489
- * [`list-selectors`] lists and categorizes the selectors used in your CSS,
490
- for code review.
491
-
492
- ### Reporters
493
-
494
- * [`postcss-browser-reporter`] displays warning messages from other plugins
495
- right in your browser.
496
- * [`postcss-reporter`] logs warnings and other messages from other plugins
497
- in the console.
498
-
499
- ### Fun
500
-
501
- * [`postcss-australian-stylesheets`] Australian Style Sheets.
502
- * [`postcss-canadian-stylesheets`] Canadian Style Sheets.
503
- * [`postcss-german-stylesheets`] German Style Sheets.
504
- * [`postcss-russian-stylesheets`] Russian Style Sheets.
505
- * [`postcss-swedish-stylesheets`] Swedish Style Sheets.
506
- * [`postcss-tatar-stylesheets`] Tatar Style Sheets
507
- * [`postcss-lolcat-stylesheets`] Lolspeak Style Sheets.
508
- * [`postcss-imperial`] adds CSS support for Imperial and US customary units of length.
509
- * [`postcss-russian-units`] adds CSS support for russian units of length.
510
- * [`postcss-pointer`] Replaces `pointer: cursor` with `cursor: pointer`.
511
- * [`postcss-spiffing`] lets you use British English in your CSS.
512
-
513
- [`postcss-pseudo-elements-content`]: https://github.com/omgovich/postcss-pseudo-elements-content
514
- [`postcss-australian-stylesheets`]: https://github.com/dp-lewis/postcss-australian-stylesheets
515
- [`postcss-pseudo-class-any-link`]: https://github.com/jonathantneal/postcss-pseudo-class-any-link
516
- [`postcss-pseudo-content-insert`]: https://github.com/liquidlight/postcss-pseudo-content-insert
517
- [`postcss-canadian-stylesheets`]: https://github.com/chancancode/postcss-canadian-stylesheets
518
- [`postcss-increase-specificity`]: https://github.com/MadLittleMods/postcss-increase-specificity
519
- [`postcss-swedish-stylesheets`]: https://github.com/johnie/postcss-swedish-stylesheets
520
- [`postcss-russian-stylesheets`]: https://github.com/Semigradsky/postcss-russian-stylesheets
521
- [`postcss-color-rebeccapurple`]: https://github.com/postcss/postcss-color-rebeccapurple
522
- [`postcss-color-rgba-fallback`]: https://github.com/postcss/postcss-color-rgba-fallback
523
- [`postcss-lolcat-stylesheets`]: https://github.com/sandralundgren/postcss-lolcat-stylesheets
524
- [`postcss-german-stylesheets`]: https://github.com/timche/postcss-german-stylesheets
525
- [`postcss-discard-duplicates`]: https://github.com/ben-eb/postcss-discard-duplicates
526
- [`postcss-minify-font-weight`]: https://github.com/ben-eb/postcss-minify-font-weight
527
- [`postcss-pseudo-class-enter`]: https://github.com/jonathantneal/postcss-pseudo-class-enter
528
- [`postcss-transform-shortcut`]: https://github.com/jonathantneal/postcss-transform-shortcut
529
- [`postcss-at-rules-variables`]: https://github.com/GitScrum/postcss-at-rules-variables
530
- [`postcss-responsive-images`]: https://github.com/azat-io/postcss-responsive-images
531
- [`postcss-tatar-stylesheets`]: https://github.com/azat-io/postcss-tatar-stylesheets
532
- [`postcss-custom-properties`]: https://github.com/postcss/postcss-custom-properties
533
- [`postcss-discard-font-face`]: https://github.com/ben-eb/postcss-discard-font-face
534
- [`postcss-custom-selectors`]: https://github.com/postcss/postcss-custom-selectors
535
- [`postcss-discard-comments`]: https://github.com/ben-eb/postcss-discard-comments
536
- [`postcss-minify-selectors`]: https://github.com/ben-eb/postcss-minify-selectors
537
- [`postcss-mqwidth-to-class`]: https://github.com/notacouch/postcss-mqwidth-to-class
538
- [`postcss-quantity-queries`]: https://github.com/pascalduez/postcss-quantity-queries
539
- [`postcss-browser-reporter`]: https://github.com/postcss/postcss-browser-reporter
540
- [`postcss-selector-matches`]: https://github.com/postcss/postcss-selector-matches
541
- [`postcss-shorthand-expand`]: https://github.com/johnotander/postcss-shorthand-expand
542
- [`postcss-all-link-colors`]: https://github.com/jedmao/postcss-all-link-colors
543
- [`postcss-color-hex-alpha`]: https://github.com/postcss/postcss-color-hex-alpha
544
- [`postcss-define-property`]: https://github.com/daleeidd/postcss-define-property
545
- [`postcss-generate-preset`]: https://github.com/simonsmith/postcss-generate-preset
546
- [`postcss-media-variables`]: https://github.com/WolfgangKluge/postcss-media-variables
547
- [`postcss-property-lookup`]: https://github.com/simonsmith/postcss-property-lookup
548
- [`postcss-vertical-rhythm`]: https://github.com/markgoodyear/postcss-vertical-rhythm
549
- [`postcss-local-constants`]: https://github.com/macropodhq/postcss-local-constants
550
- [`postcss-remove-prefixes`]: https://github.com/johnotander/postcss-remove-prefixes
551
- [`postcss-responsive-type`]: https://github.com/seaneking/postcss-responsive-type
552
- [`postcss-round-subpixels`]: https://github.com/himynameisdave/postcss-round-subpixels
553
- [`postcss-short-font-size`]: https://github.com/jonathantneal/postcss-short-font-size
554
- [`postcss-color-function`]: https://github.com/postcss/postcss-color-function
555
- [`postcss-conic-gradient`]: https://github.com/jonathantneal/postcss-conic-gradient
556
- [`postcss-convert-values`]: https://github.com/ben-eb/postcss-convert-values
557
- [`postcss-partial-import`]: https://github.com/jonathantneal/postcss-partial-import
558
- [`postcss-pseudoelements`]: https://github.com/axa-ch/postcss-pseudoelements
559
- [`postcss-short-position`]: https://github.com/jonathantneal/postcss-short-position
560
- [`postcss-single-charset`]: https://github.com/hail2u/postcss-single-charset
561
- [`postcss-flexbugs-fixes`]: https://github.com/luisrudge/postcss-flexbugs-fixes
562
- [`postcss-alias-atrules`]: https://github.com/maximkoretskiy/postcss-alias-atrules
563
- [`postcss-color-palette`]: https://github.com/zaim/postcss-color-palette
564
- [`postcss-color-pantone`]: https://github.com/longdog/postcss-color-pantone
565
- [`postcss-css-variables`]: https://github.com/MadLittleMods/postcss-css-variables
566
- [`postcss-discard-empty`]: https://github.com/ben-eb/postcss-discard-empty
567
- [`postcss-gradientfixer`]: https://github.com/hallvors/postcss-gradientfixer
568
- [`postcss-modular-scale`]: https://github.com/kristoferjoseph/postcss-modular-scale
569
- [`postcss-normalize-url`]: https://github.com/ben-eb/postcss-normalize-url
570
- [`postcss-reduce-idents`]: https://github.com/ben-eb/postcss-reduce-idents
571
- [`postcss-short-spacing`]: https://github.com/jonathantneal/postcss-short-spacing
572
- [`postcss-simple-extend`]: https://github.com/davidtheclark/postcss-simple-extend
573
- [`postcss-russian-units`]: https://github.com/Semigradsky/postcss-russian-units
574
- [`postcss-image-inliner`]: https://github.com/bezoerb/postcss-image-inliner
575
- [`postcss-mq-keyframes`]: https://github.com/TCotton/postcss-mq-keyframes
576
- [`postcss-brand-colors`]: https://github.com/postcss/postcss-brand-colors
577
- [`postcss-class-prefix`]: https://github.com/thompsongl/postcss-class-prefix
578
- [`postcss-conditionals`]: https://github.com/andyjansson/postcss-conditionals
579
- [`postcss-reverse-media`]: https://github.com/MadLittleMods/postcss-reverse-media
580
- [`postcss-sassy-mixins`]: https://github.com/andyjansson/postcss-sassy-mixins
581
- [`postcss-custom-media`]: https://github.com/postcss/postcss-custom-media
582
- [`postcss-default-unit`]: https://github.com/antyakushev/postcss-default-unit
583
- [`postcss-flexboxfixer`]: https://github.com/hallvors/postcss-flexboxfixer
584
- [`postcss-font-variant`]: https://github.com/postcss/postcss-font-variant
585
- [`postcss-media-minmax`]: https://github.com/postcss/postcss-media-minmax
586
- [`postcss-merge-idents`]: https://github.com/ben-eb/postcss-merge-idents
587
- [`postcss-selector-not`]: https://github.com/postcss/postcss-selector-not
588
- [`postcss-svg-fallback`]: https://github.com/justim/postcss-svg-fallback
589
- [`postcss-nested-props`]: https://github.com/jedmao/postcss-nested-props
590
- [`postcss-nested-vars`]: https://github.com/jedmao/postcss-nested-vars
591
- [`postcss-color-alpha`]: https://github.com/avanes/postcss-color-alpha
592
- [`postcss-color-scale`]: https://github.com/kristoferjoseph/postcss-color-scale
593
- [`postcss-color-short`]: https://github.com/andrepolischuk/postcss-color-short
594
- [`postcss-copy-assets`]: https://github.com/shutterstock/postcss-copy-assets
595
- [`postcss-data-packer`]: https://github.com/Ser-Gen/postcss-data-packer
596
- [`postcss-font-family`]: https://github.com/ben-eb/postcss-font-family
597
- [`postcss-simple-grid`]: https://github.com/admdh/postcss-simple-grid
598
- [`postcss-merge-rules`]: https://github.com/ben-eb/postcss-merge-rules
599
- [`postcss-simple-vars`]: https://github.com/postcss/postcss-simple-vars
600
- [`postcss-strip-units`]: https://github.com/whitneyit/postcss-strip-units
601
- [`postcss-style-guide`]: https://github.com/morishitter/postcss-style-guide
602
- [`postcss-will-change`]: https://github.com/postcss/postcss-will-change
603
- [`postcss-input-style`]: https://github.com/seaneking/postcss-input-style
604
- [`postcss-ase-colors`]: https://github.com/dfernandez79/postcss-ase-colors
605
- [`postcss-bem-linter`]: https://github.com/necolas/postcss-bem-linter
606
- [`postcss-color-gray`]: https://github.com/postcss/postcss-color-gray
607
- [`postcss-colorblind`]: https://github.com/btholt/postcss-colorblind
608
- [`postcss-color-hexa`]: https://github.com/nicksheffield/postcss-color-hexa
609
- [`postcss-short-text`]: https://github.com/jonathantneal/postcss-short-text
610
- [`postcss-autoreset`]: https://github.com/maximkoretskiy/postcss-autoreset
611
- [`postcss-font-pack`]: https://github.com/jedmao/postcss-font-pack
612
- [`postcss-functions`]: https://github.com/andyjansson/postcss-functions
613
- [`postcss-color-hcl`]: https://github.com/devgru/postcss-color-hcl
614
- [`postcss-color-hwb`]: https://github.com/postcss/postcss-color-hwb
615
- [`postcss-color-mix`]: https://github.com/iamstarkov/postcss-color-mix
616
- [`postcss-color-yiq`]: https://github.com/ben-eb/postcss-color-yiq
617
- [`postcss-image-set`]: https://github.com/alex499/postcss-image-set
618
- [`postcss-write-svg`]: https://github.com/jonathantneal/postcss-write-svg
619
- [`postcss-instagram`]: https://github.com/azat-io/postcss-instagram
620
- [`postcss-clearfix`]: https://github.com/seaneking/postcss-clearfix
621
- [`postcss-colormin`]: https://github.com/ben-eb/colormin
622
- [`postcss-cssstats`]: https://github.com/cssstats/postcss-cssstats
623
- [`postcss-currency`]: https://github.com/talgautb/postcss-currency
624
- [`postcss-imperial`]: https://github.com/cbas/postcss-imperial
625
- [`postcss-position`]: https://github.com/seaneking/postcss-position
626
- [`postcss-spiffing`]: https://github.com/HashanP/postcss-spiffing
627
- [`postcss-triangle`]: https://github.com/jedmao/postcss-triangle
628
- [`postcss-verthorz`]: https://github.com/davidhemphill/postcss-verthorz
629
- [`pleeease-filters`]: https://github.com/iamvdo/pleeease-filters
630
- [`postcss-fontpath`]: https://github.com/seaneking/postcss-fontpath
631
- [`postcss-reporter`]: https://github.com/postcss/postcss-reporter
632
- [`postcss-easings`]: https://github.com/postcss/postcss-easings
633
- [`postcss-hexrgba`]: https://github.com/seaneking/postcss-hexrgba
634
- [`postcss-initial`]: https://github.com/maximkoretskiy/postcss-initial
635
- [`postcss-rgb-plz`]: https://github.com/himynameisdave/postcss-rgb-plz
636
- [`postcss-opacity`]: https://github.com/iamvdo/postcss-opacity
637
- [`postcss-pointer`]: https://github.com/markgoodyear/postcss-pointer
638
- [`postcss-pxtorem`]: https://github.com/cuth/postcss-pxtorem
639
- [`postcss-scopify`]: https://github.com/pazams/postcss-scopify
640
- [`postcss-sprites`]: https://github.com/2createStudio/postcss-sprites
641
- [`postcss-assets`]: https://github.com/borodean/postcss-assets
642
- [`postcss-border`]: https://github.com/andrepolischuk/postcss-border
643
- [`postcss-center`]: https://github.com/jedmao/postcss-center
644
- [`postcss-circle`]: https://github.com/jedmao/postcss-circle
645
- [`postcss-urlrev`]: https://github.com/yuezk/postcss-urlrev
646
- [`postcss-extend`]: https://github.com/travco/postcss-extend
647
- [`postcss-fakeid`]: https://github.com/pathsofdesign/postcss-fakeid
648
- [`postcss-filter`]: https://github.com/alanev/postcss-filter
649
- [`postcss-import`]: https://github.com/postcss/postcss-import
650
- [`postcss-mixins`]: https://github.com/postcss/postcss-mixins
651
- [`postcss-nested`]: https://github.com/postcss/postcss-nested
652
- [`postcss-zindex`]: https://github.com/ben-eb/postcss-zindex
653
- [`list-selectors`]: https://github.com/davidtheclark/list-selectors
654
- [`mq4-hover-shim`]: https://github.com/twbs/mq4-hover-shim
655
- [`postcss-atroot`]: https://github.com/OEvgeny/postcss-atroot
656
- [`postcss-focus`]: https://github.com/postcss/postcss-focus
657
- [`postcss-apply`]: https://github.com/pascalduez/postcss-apply
658
- [`css2modernizr`]: https://github.com/vovanbo/css2modernizr
659
- [`font-magician`]: https://github.com/jonathantneal/postcss-font-magician
660
- [`postcss-match`]: https://github.com/rtsao/postcss-match
661
- [`postcss-alias`]: https://github.com/seaneking/postcss-alias
662
- [`perfectionist`]: https://github.com/ben-eb/perfectionist
663
- [`immutable-css`]: https://github.com/johnotander/immutable-css
664
- [`postcss-at2x`]: https://github.com/simonsmith/postcss-at2x
665
- [`postcss-calc`]: https://github.com/postcss/postcss-calc
666
- [`postcss-crip`]: https://github.com/johnie/postcss-crip
667
- [`postcss-each`]: https://github.com/outpunk/postcss-each
668
- [`postcss-epub`]: https://github.com/Rycochet/postcss-epub
669
- [`postcss-grid`]: https://github.com/andyjansson/postcss-grid
670
- [`postcss-host`]: https://github.com/vitkarpov/postcss-host
671
- [`postcss-neat`]: https://github.com/jo-asakura/postcss-neat
672
- [`postcss-size`]: https://github.com/postcss/postcss-size
673
- [`postcss-svgo`]: https://github.com/ben-eb/postcss-svgo
674
- [`postcss-unmq`]: https://github.com/jonathantneal/postcss-unmq
675
- [`postcss-vmin`]: https://github.com/iamvdo/postcss-vmin
676
- [`autoprefixer`]: https://github.com/postcss/autoprefixer
677
- [`css-mqpacker`]: https://github.com/hail2u/node-css-mqpacker
678
- [`postcss-bem`]: https://github.com/ileri/postcss-bem
679
- [`postcss-for`]: https://github.com/antyakushev/postcss-for
680
- [`postcss-map`]: https://github.com/pascalduez/postcss-map
681
- [`postcss-svg`]: https://github.com/Pavliko/postcss-svg
682
- [`postcss-url`]: https://github.com/postcss/postcss-url
683
- [`colorguard`]: https://github.com/SlexAxton/css-colorguard
684
- [`stylehacks`]: https://github.com/ben-eb/stylehacks
685
- [`css-byebye`]: https://github.com/AoDev/css-byebye
686
- [`cssgrace`]: https://github.com/cssdream/cssgrace
687
- [`csstyle`]: https://github.com/geddski/csstyle
688
- [`webpcss`]: https://github.com/lexich/webpcss
689
- [`cssfmt`]: https://github.com/morishitter/cssfmt
690
- [`doiuse`]: https://github.com/anandthakker/doiuse
691
- [`pixrem`]: https://github.com/robwierzbowski/node-pixrem
692
- [`rtlcss`]: https://github.com/MohammadYounes/rtlcss
693
- [`short`]: https://github.com/jonathantneal/postcss-short
694
- [`lost`]: https://github.com/corysimmons/lost
695
-
696
- ## How to Develop for PostCSS
697
-
698
- ### Syntax
699
-
700
- * [How to Write Custom Syntax](https://github.com/postcss/postcss/blob/master/docs/syntax.md)
701
-
702
- ### Plugin
703
-
704
- * [Plugin Guidelines](https://github.com/postcss/postcss/blob/master/docs/guidelines/plugin.md)
705
- * [Plugin Boilerplate](https://github.com/postcss/postcss-plugin-boilerplate)
706
- * [PostCSS API](https://github.com/postcss/postcss/blob/master/docs/api.md)
707
- * [Ask questions](https://gitter.im/postcss/postcss)
708
-
709
- ## Options
710
-
711
- ### Source Map
712
-
713
- PostCSS has great [source maps] support. It can read and interpret maps
714
- from previous transformation steps, autodetect the format that you expect,
715
- and output both external and inline maps.
716
-
717
- To ensure that you generate an accurate source map, you must indicate the input
718
- and output CSS file paths — using the options `from` and `to`, respectively.
719
-
720
- To generate a new source map with the default options, simply set `map: true`.
721
- This will generate an inline source map that contains the source content.
722
- If you don’t want the map inlined, you can set `map.inline: false`.
210
+ For other environments, you can use the [CLI tool] or the JS API:
723
211
 
724
212
  ```js
725
- processor
726
- .process(css, {
727
- from: 'app.sass.css',
728
- to: 'app.css',
729
- map: { inline: false },
730
- })
213
+ var postcss = require('postcss');
214
+ postcss([ require('autoprefixer'), require('cssnano') ])
215
+ .process(css, { from: 'src/app.css', to: 'app.css' })
731
216
  .then(function (result) {
732
- result.map //=> '{ "version":3,
733
- // "file":"app.css",
734
- // "sources":["app.sass"],
735
- // "mappings":"AAAA,KAAI" }'
217
+ fs.writeFileSync('app.css', result.css);
218
+ if ( result.map ) fs.writeFileSync('app.css.map', result.map);
736
219
  });
737
220
  ```
738
221
 
739
- If PostCSS finds source maps from a previous transformation,
740
- it will automatically update that source map with the same options.
222
+ Read the [PostCSS API documentation] for more details about the JS API.
223
+
224
+ All PostCSS JS API users should pass [PostCSS Runner Guidelines].
225
+
226
+ [PostCSS Runner Guidelines]: https://github.com/postcss/postcss/blob/master/docs/guidelines/runner.md
227
+ [PostCSS API documentation]: https://github.com/postcss/postcss/blob/master/docs/api.md
228
+ [CLI tool]: https://github.com/code42day/postcss-cli
741
229
 
742
- If you want more control over source map generation, you can define the `map`
743
- option as an object with the following parameters:
230
+ ### Options
744
231
 
745
- * `inline` boolean: indicates that the source map should be embedded
746
- in the output CSS as a Base64-encoded comment. By default, it is `true`.
747
- But if all previous maps are external, not inline, PostCSS will not embed
748
- the map even if you do not set this option.
232
+ Most PostCSS runners accept two parameters:
749
233
 
750
- If you have an inline source map, the `result.map` property will be empty,
751
- as the source map will be contained within the text of `result.css`.
234
+ * An array of plugins.
235
+ * An object of options.
752
236
 
753
- * `prev` string, object or boolean: source map content from
754
- a previous processing step (for example, Sass compilation).
755
- PostCSS will try to read the previous source map automatically
756
- (based on comments within the source CSS), but you can use this option
757
- to identify it manually. If desired, you can omit the previous map
758
- with `prev: false`.
237
+ Common options:
759
238
 
760
- * `sourcesContent` boolean: indicates that PostCSS should set the origin
761
- content (for example, Sass source) of the source map. By default,
762
- it is `true`. But if all previous maps do not contain sources content,
763
- PostCSS will also leave it out even if you do not set this option.
239
+ * `syntax`: object with syntax parser and stringifier.
240
+ * `parser`: other syntax parser (for example, [SCSS]).
241
+ * `stringifier`: other syntax output generator (for example, [Midas]).
242
+ * `map`: [source map options].
243
+ * `from`: input file name (most runners set it automatically).
244
+ * `to`: output file name (most runners set it automatically).
764
245
 
765
- * `annotation` boolean or string: indicates that PostCSS should add annotation
766
- comments to the CSS. By default, PostCSS will always add a comment with a path
767
- to the source map. PostCSS will not add annotations to CSS files that
768
- do not contain any comments.
246
+ [source map options]: https://github.com/postcss/postcss/blob/master/docs/source-maps.md
247
+ [Midas]: https://github.com/ben-eb/midas
248
+ [SCSS]: https://github.com/postcss/postcss-scss
769
249
 
770
- By default, PostCSS presumes that you want to save the source map as
771
- `opts.to + '.map'` and will use this path in the annotation comment.
772
- A different path can be set by providing a string value for `annotation`.
250
+ ### Node.js 0.10 and the Promise API
773
251
 
774
- If you have set `inline: true`, annotation cannot be disabled.
252
+ If you want to run PostCSS on node.js 0.10, add the [Promise polyfill]:
775
253
 
776
- [source maps]: http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/
254
+ ```js
255
+ require('es6-promise').polyfill();
256
+ var postcss = require('postcss');
257
+ ```
258
+
259
+ [Promise polyfill]: https://github.com/jakearchibald/es6-promise