File tree 2 files changed +57
-0
lines changed 2 files changed +57
-0
lines changed Original file line number Diff line number Diff line change @@ -30,6 +30,26 @@ gulp.task('css', function () {
30
30
});
31
31
```
32
32
33
+ ## Passing additional options to PostCSS
34
+
35
+ The second optional argument to gulp-postcss is passed to PostCSS.
36
+
37
+ This, for instance, may be used to enable custom syntax:
38
+
39
+ ``` js
40
+ var gulp = require (' gulp' );
41
+ var postcss = require (' gulp-postcss' );
42
+ var nested = require (' postcss-nested' );
43
+ var scss = require (' postcss-scss' );
44
+
45
+ gulp .task (' default' , function () {
46
+ var processors = [nested];
47
+ return gulp .src (' in.css' )
48
+ .pipe (postcss (processors, {syntax: scss}))
49
+ .pipe (gulp .dest (' out' ));
50
+ });
51
+ ```
52
+
33
53
## Using a custom processor
34
54
35
55
``` js
@@ -74,6 +94,9 @@ return gulp.src('./src/*.css')
74
94
75
95
## Changelog
76
96
97
+ * 6.0.1
98
+ * Added an example and a test to pass options to PostCSS (e.g. ` syntax ` option)
99
+
77
100
* 6.0.0
78
101
* Updated PostCSS to version 5.0.0
79
102
Original file line number Diff line number Diff line change @@ -245,6 +245,40 @@ describe('PostCSS Guidelines', function () {
245
245
246
246
} )
247
247
248
+ it ( 'should pass options down to PostCSS' , function ( cb ) {
249
+
250
+ var customSyntax = function ( ) { }
251
+ var options = {
252
+ syntax : customSyntax
253
+ }
254
+
255
+ var stream = postcss ( [ doubler ] , options )
256
+ var cssPath = __dirname + '/src/fixture.css'
257
+ postcssStub . process . returns ( Promise . resolve ( {
258
+ css : ''
259
+ , warnings : function ( ) {
260
+ return [ ]
261
+ }
262
+ } ) )
263
+
264
+ stream . on ( 'data' , function ( ) {
265
+ var resultOptions = postcssStub . process . getCall ( 0 ) . args [ 1 ]
266
+ // remove automatically set options
267
+ delete resultOptions . from
268
+ delete resultOptions . to
269
+ delete resultOptions . map
270
+ assert . deepEqual ( resultOptions , options )
271
+ cb ( )
272
+ } )
273
+
274
+ stream . write ( new gutil . File ( {
275
+ contents : new Buffer ( 'a {}' )
276
+ , path : cssPath
277
+ } ) )
278
+
279
+ stream . end ( )
280
+
281
+ } )
248
282
249
283
} )
250
284
You can’t perform that action at this time.
0 commit comments