Skip to content

Commit 9c19592

Browse files
author
Andrey Kuzmin
committed
Update readme
1 parent e0714ec commit 9c19592

File tree

3 files changed

+36
-19
lines changed

3 files changed

+36
-19
lines changed

README.md

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# gulp-postcss [![Build Status](https://api.travis-ci.org/postcss/gulp-postcss.png)](https://travis-ci.org/postcss/gulp-postcss)
22

33
[PostCSS](https://github.com/postcss/postcss) gulp plugin to pipe CSS through
4-
several processors, but parse CSS only once.
4+
several plugins, but parse CSS only once.
55

66
## Install
77

@@ -11,19 +11,36 @@ Install required [postcss plugins](https://www.npmjs.com/browse/keyword/postcss-
1111

1212
## Basic usage
1313

14+
The configuration is loaded automatically from `postcss.config.js`
15+
as [described here](https://www.npmjs.com/package/postcss-load-config),
16+
so you don't have to specify any options.
17+
18+
```js
19+
var postcss = require('gulp-postcss');
20+
var gulp = require('gulp');
21+
22+
gulp.task('css', function () {
23+
return gulp.src('./src/*.css')
24+
.pipe(postcss())
25+
.pipe(gulp.dest('./dest'));
26+
});
27+
```
28+
29+
## Passing plugins directly
30+
1431
```js
1532
var postcss = require('gulp-postcss');
1633
var gulp = require('gulp');
1734
var autoprefixer = require('autoprefixer');
1835
var cssnano = require('cssnano');
1936

2037
gulp.task('css', function () {
21-
var processors = [
38+
var plugins = [
2239
autoprefixer({browsers: ['last 1 version']}),
23-
cssnano(),
40+
cssnano()
2441
];
2542
return gulp.src('./src/*.css')
26-
.pipe(postcss(processors))
43+
.pipe(postcss(plugins))
2744
.pipe(gulp.dest('./dest'));
2845
});
2946
```
@@ -41,9 +58,9 @@ var nested = require('postcss-nested');
4158
var scss = require('postcss-scss');
4259

4360
gulp.task('default', function () {
44-
var processors = [nested];
61+
var plugins = [nested];
4562
return gulp.src('in.css')
46-
.pipe(postcss(processors, {syntax: scss}))
63+
.pipe(postcss(plugins, {syntax: scss}))
4764
.pipe(gulp.dest('out'));
4865
});
4966
```
@@ -65,12 +82,12 @@ var opacity = function (css, opts) {
6582
};
6683

6784
gulp.task('css', function () {
68-
var processors = [
85+
var plugins = [
6986
cssnext({browsers: ['last 1 version']}),
70-
opacity,
87+
opacity
7188
];
7289
return gulp.src('./src/*.css')
73-
.pipe(postcss(processors))
90+
.pipe(postcss(plugins))
7491
.pipe(gulp.dest('./dest'));
7592
});
7693
```
@@ -83,7 +100,7 @@ with [gulp-sourcemaps](https://github.com/floridoo/gulp-sourcemaps).
83100
```js
84101
return gulp.src('./src/*.css')
85102
.pipe(sourcemaps.init())
86-
.pipe(postcss(processors))
103+
.pipe(postcss(plugins))
87104
.pipe(sourcemaps.write('.'))
88105
.pipe(gulp.dest('./dest'));
89106
```
@@ -124,7 +141,7 @@ return gulp.src('./src/*.css')
124141

125142
* 5.1.4
126143
* Simplified error handling
127-
* Simplified postcss execution with object processors
144+
* Simplified postcss execution with object plugins
128145

129146
* 5.1.3 Updated travis banner
130147

@@ -139,7 +156,7 @@ return gulp.src('./src/*.css')
139156
* Display `result.warnings()` content
140157

141158
* 5.0.1
142-
* Fix to support object processors
159+
* Fix to support object plugins
143160

144161
* 5.0.0
145162
* Use async API
@@ -173,7 +190,7 @@ return gulp.src('./src/*.css')
173190
* Improved README
174191

175192
* 1.0.1
176-
* Don't add source map comment if used with gulp-sourcemap
193+
* Don't add source map comment if used with gulp-sourcemaps
177194

178195
* 1.0.0
179196
* Initial release

index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@ module.exports = withConfigLoader(function (loadConfig) {
2020
return handleError('Streams are not supported!')
2121
}
2222

23-
// Protect `from` and `map` if using gulp-sourcemap
23+
// Protect `from` and `map` if using gulp-sourcemaps
2424
var isProtected = file.sourceMap
2525
? { from: true, map: true }
2626
: {}
2727

2828
var options = {
2929
from: file.path
3030
, to: file.path
31-
// Generate a separate source map for gulp-sourcemap
31+
// Generate a separate source map for gulp-sourcemaps
3232
, map: file.sourceMap ? { annotation: false } : false
3333
}
3434

@@ -47,7 +47,7 @@ module.exports = withConfigLoader(function (loadConfig) {
4747
gutil.log(
4848
'gulp-postcss:',
4949
file.relative + '\nCannot override ' + opt +
50-
' option, because it is required by gulp-sourcemap'
50+
' option, because it is required by gulp-sourcemaps'
5151
)
5252
}
5353
}

test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ describe('PostCSS Guidelines', function () {
280280

281281
})
282282

283-
it('should not override `from` and `map` if using source maps', function (cb) {
283+
it('should not override `from` and `map` if using gulp-sourcemaps', function (cb) {
284284
var stream = postcss([ doubler ], { from: 'overriden', map: 'overriden' })
285285
var cssPath = __dirname + '/fixture.css'
286286
postcssStub.process.returns(Promise.resolve({
@@ -305,8 +305,8 @@ describe('PostCSS Guidelines', function () {
305305
assert.deepEqual(postcssStub.process.getCall(0).args[1].map, { annotation: false })
306306
var firstMessage = gutil.log.getCall(0).args[1]
307307
var secondMessage = gutil.log.getCall(1).args[1]
308-
assert(firstMessage, '/fixture.css\nCannot override from option, because it is required by gulp-sourcemap')
309-
assert(secondMessage, '/fixture.css\nCannot override map option, because it is required by gulp-sourcemap')
308+
assert(firstMessage, '/fixture.css\nCannot override from option, because it is required by gulp-sourcemaps')
309+
assert(secondMessage, '/fixture.css\nCannot override map option, because it is required by gulp-sourcemaps')
310310
cb()
311311
})
312312

0 commit comments

Comments
 (0)