Skip to content

Commit 2c27a10

Browse files
committed
Expand plugin use examples in doc #3
1 parent dbc8da1 commit 2c27a10

File tree

1 file changed

+36
-15
lines changed

1 file changed

+36
-15
lines changed

README.md

Lines changed: 36 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,35 +11,56 @@
1111

1212
Prefix every rule with a selector.
1313

14-
```js
15-
var css = '.a {} \n.b{}'
14+
## Installation
15+
16+
```console
17+
$ npm install postcss-prefix-selector
18+
```
1619

20+
## Usage
21+
22+
```js
1723
var prefix = require('postcss-prefix-selector')
1824

25+
// css to be processed
26+
var css = fs.readFileSync("input.css", "utf8")
27+
1928
var out = postcss().use(prefix({
20-
prefix: '.some-selector ' // <--- notice the traililng space!
29+
prefix: '.some-selector ', // <--- notice the traililng space!
30+
exclude: ['.c']
2131
})).process(css).css
22-
23-
console.log(out)
2432
```
2533

26-
## Options
34+
Using this `input.css`:
2735

28-
It's possible to avoid prefixing some selectors with the option `exclude` which take an array of selectors in parameter.
36+
```css
37+
.a, .b {
38+
color: aqua;
39+
}
2940

30-
```js
31-
var css = '.a {} \nhtml{} \n.b{}'
41+
.c {
42+
color: coral;
43+
}
44+
```
3245

33-
var prefix = require('postcss-prefix-selector')
46+
you will get:
3447

35-
var out = postcss().use(prefix({
36-
prefix: '.some-selector ', // <--- notice the traililng space!
37-
exclude: ['html', '.b']
38-
})).process(css).css
48+
```css
49+
.some-selector .a, .some-selector .b {
50+
color: aqua;
51+
}
3952

40-
console.log(out)
53+
.c {
54+
color: coral;
55+
}
4156
```
4257

58+
59+
## Options
60+
61+
It's possible to avoid prefixing some selectors by using the `exclude` option which takes an array of selectors as a parameter.
62+
63+
4364
[gitter-image]: https://badges.gitter.im/jonathanong/postcss-prefix-selector.png
4465
[gitter-url]: https://gitter.im/jonathanong/postcss-prefix-selector
4566
[npm-image]: https://img.shields.io/npm/v/postcss-prefix-selector.svg?style=flat-square

0 commit comments

Comments
 (0)