Skip to content

Commit

Permalink
Add a note about synchronous versus asynchronous speed
Browse files Browse the repository at this point in the history
  • Loading branch information
nex3 authored and xzyfer committed Oct 16, 2018
1 parent 7cc2db1 commit 938afbe
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions README.md
Expand Up @@ -56,6 +56,26 @@ gulp.task('sass:watch', function () {
});
```

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:

```javascript
'use strict';

var Fiber = require('fibers');
var gulp = require('gulp');
var sass = require('gulp-sass')(require('sass'));

gulp.task('sass', function () {
return gulp.src('./sass/**/*.scss')
.pipe(sass({fiber: Fiber}).on('error', sass.logError))
.pipe(gulp.dest('./css'));
});

gulp.task('sass:watch', function () {
gulp.watch('./sass/**/*.scss', ['sass']);
});
```

## Options

`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.
Expand Down

0 comments on commit 938afbe

Please sign in to comment.