1 | # [postcss][postcss]-merge-rules [![Build Status](https://travis-ci.org/ben-eb/postcss-merge-rules.svg?branch=master)][ci] [![NPM version](https://badge.fury.io/js/postcss-merge-rules.svg)][npm] [![Dependency Status](https://gemnasium.com/ben-eb/postcss-merge-rules.svg)][deps]
|
2 |
|
3 | > Merge CSS rules with PostCSS.
|
4 |
|
5 | ## Install
|
6 |
|
7 | With [npm](https://npmjs.org/package/postcss-merge-rules) do:
|
8 |
|
9 | ```
|
10 | npm install postcss-merge-rules --save
|
11 | ```
|
12 |
|
13 | ## Examples
|
14 |
|
15 | This module will attempt to merge *adjacent* CSS rules:
|
16 |
|
17 | ### By declarations
|
18 |
|
19 | #### Input
|
20 |
|
21 | ```css
|
22 | a {
|
23 | color: blue;
|
24 | font-weight: bold
|
25 | }
|
26 |
|
27 | p {
|
28 | color: blue;
|
29 | font-weight: bold
|
30 | }
|
31 | ```
|
32 |
|
33 | #### Output
|
34 |
|
35 | ```css
|
36 | a,p {
|
37 | color: blue;
|
38 | font-weight: bold
|
39 | }
|
40 | ```
|
41 |
|
42 | ### By selectors
|
43 |
|
44 | #### Input
|
45 |
|
46 | ```css
|
47 | a {
|
48 | color: blue
|
49 | }
|
50 |
|
51 | a {
|
52 | font-weight: bold
|
53 | }
|
54 | ```
|
55 |
|
56 | #### Output
|
57 |
|
58 | ```css
|
59 | a {
|
60 | color: blue;
|
61 | font-weight: bold
|
62 | }
|
63 | ```
|
64 |
|
65 | ### By partial declarations
|
66 |
|
67 | #### Input
|
68 |
|
69 | ```css
|
70 | a {
|
71 | font-weight: bold
|
72 | }
|
73 |
|
74 | p {
|
75 | color: blue;
|
76 | font-weight: bold
|
77 | }
|
78 | ```
|
79 |
|
80 | #### Output
|
81 |
|
82 | ```css
|
83 | a,p {
|
84 | font-weight: bold
|
85 | }
|
86 |
|
87 | p {
|
88 | color: blue
|
89 | }
|
90 | ```
|
91 |
|
92 | ## Usage
|
93 |
|
94 | See the [PostCSS documentation](https://github.com/postcss/postcss#usage) for
|
95 | examples for your environment.
|
96 |
|
97 | ## Contributing
|
98 |
|
99 | Pull requests are welcome. If you add functionality, then please add unit tests
|
100 | to cover it.
|
101 |
|
102 | ## License
|
103 |
|
104 | MIT © [Ben Briggs](http://beneb.info)
|
105 |
|
106 | [ci]: https://travis-ci.org/ben-eb/postcss-merge-rules
|
107 | [deps]: https://gemnasium.com/ben-eb/postcss-merge-rules
|
108 | [npm]: http://badge.fury.io/js/postcss-merge-rules
|
109 | [postcss]: https://github.com/postcss/postcss
|