Skip to content

Commit 938afbe

Browse files
nex3xzyfer
authored andcommittedOct 16, 2018
Add a note about synchronous versus asynchronous speed
1 parent 7cc2db1 commit 938afbe

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed
 

‎README.md

+20
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,26 @@ gulp.task('sass:watch', function () {
5656
});
5757
```
5858

59+
Note that when using Dart Sass, **synchronous compilation is twice as fast as asynchronous compilation** by default, due to the overhead of asynchronous callbacks. To avoid this overhead, you can use the [`fibers`](https://www.npmjs.com/package/fibers) package to call asynchronous importers from the synchronous code path. To enable this, pass the `Fiber` class to the `fiber` option:
60+
61+
```javascript
62+
'use strict';
63+
64+
var Fiber = require('fibers');
65+
var gulp = require('gulp');
66+
var sass = require('gulp-sass')(require('sass'));
67+
68+
gulp.task('sass', function () {
69+
return gulp.src('./sass/**/*.scss')
70+
.pipe(sass({fiber: Fiber}).on('error', sass.logError))
71+
.pipe(gulp.dest('./css'));
72+
});
73+
74+
gulp.task('sass:watch', function () {
75+
gulp.watch('./sass/**/*.scss', ['sass']);
76+
});
77+
```
78+
5979
## Options
6080

6181
`gulp-sass` supports both [Dart Sass][] and [Node Sass][]. You choose which one to use by writing either `require('gulp-sass')(require('sass'))` for Dart Sass or `require('gulp-sass')(require('node-sass'))` for Node Sass. One or the other must be passed in.

0 commit comments

Comments
 (0)
Please sign in to comment.