Skip to content

Commit 978b8f6

Browse files
mxmasonxzyfer
andauthoredJun 25, 2021
Update to major version 5 (#802)
* Update node-sass to 6.0.0 Also moves node-sass to devDependencies and peerDependencies. This helps prevent dupes and conflicts in packages using gulp-sass * Make mocha test compatible with gulp@4 * Update package version, engines * Remove node-sass as peer dependency * Replace through2 with transfob * Uninstall through2 * Throw error if compiler not set * Fix casing of Sass Co-authored-by: Michael Mifsud <xzyfer@gmail.com> * Use function arg to set compiler, use transfob package * Update test to new API signature * Update package versions * Fix eslint errors * Incorporate previously proposed documentation changes Copied from #694 * Update document outline, apply copyedits * Copyedit: overall clarifications * Call out migration guide, update badges * Document Gulp 4 usage * smol clarification * Copyedit some headings * Yet Another Copyedit™ * Update README.md Co-authored-by: Michael Mifsud <xzyfer@gmail.com>
1 parent 10eae93 commit 978b8f6

File tree

5 files changed

+194
-159
lines changed

5 files changed

+194
-159
lines changed
 

‎CONTRIBUTING.md

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
# Contributing to Gulp Sass
22

3-
Gulp Sass is a very light-weight [Gulp](https://github.com/gulpjs/gulp) wrapper for [`node-sass`](https://github.com/sass/node-sass), which in turn is a Node binding for [`libsass`](https://github.com/sass/libsass), which in turn is a port of [`Sass`](https://github.com/sass/sass).
3+
`gulp-sass` is a very light-weight wrapper around either [Dart Sass][] or [Node Sass][] (which in turn is a Node binding for [LibSass][]. All of these are implementations of the [Sass][] language.
4+
5+
[Dart Sass]: http://sass-lang.com/dart-sass
6+
[Node Sass]: https://github.com/sass/node-sass
7+
[LibSass]: https://sass-lang.com/libsass
8+
[Sass]: https://sass-lang.com
49

510
## Submitting Issues
611

7-
* Before creating a new issue, perform a [cursory search](https://github.com/issues?utf8=%E2%9C%93&q=repo%3Adlmanning%2Fgulp-sass+repo%3Asass%2Fnode-sass+repo%3Asass%2Flibsass+repo%3Asass%2Fsass+repo%3Asass-eyeglass%2Feyeglass) in the Gulp Sass, Node Sass, Libsass, and main Sass repos to see if a similar issue has already been submitted. Please also refer to our [Common Issues and Their Fixes](https://github.com/dlmanning/gulp-sass/wiki/Common-Issues-and-Their-Fixes) page for some basic troubleshooting.
12+
* Before creating a new issue, perform a [cursory search](https://github.com/issues?utf8=%E2%9C%93&q=repo%3Adlmanning%2Fgulp-sass+repo%3Asass%2Fdart-sass+repo%3Asass%2Fnode-sass+repo%3Asass%2Flibsass+repo%3Asass%2Fsass+repo%3Asass-eyeglass%2Feyeglass) in the Gulp Sass, Dart Sass, Node Sass, Libsass, and main Sass repos to see if a similar issue has already been submitted. Please also refer to our [Common Issues and Their Fixes](https://github.com/dlmanning/gulp-sass/wiki/Common-Issues-and-Their-Fixes) page for some basic troubleshooting.
813
* You can create an issue [here](https://github.com/dlmanning/gulp-sass/issues). Please include as many details as possible in your report.
914
* Issue titles should be descriptive, explaining at the high level what it is about.
1015
* Please include the version of `gulp-sass`, Node, and NPM you are using, as well as what operating system you are having a problem on.
@@ -60,4 +65,4 @@ When creating creating commits or updating the CHANGELOG, please **start** the c
6065
* :arrow_up: `:arrow_up:` when upgrading dependencies
6166
* :arrow_down: `:arrow_down:` when downgrading dependencies
6267
* :shirt: `:shirt:` when removing linter warnings
63-
* :shipit: `:shipit:` when creating a new release
68+
* :shipit: `:shipit:` when creating a new release

‎README.md

+100-84
Original file line numberDiff line numberDiff line change
@@ -1,154 +1,170 @@
1-
# gulp-sass [![Build Status](https://travis-ci.org/dlmanning/gulp-sass.svg?branch=master)](https://travis-ci.org/dlmanning/gulp-sass) [![Join the chat at https://gitter.im/dlmanning/gulp-sass](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/dlmanning/gulp-sass?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![npm version](https://badge.fury.io/js/gulp-sass.svg)](http://badge.fury.io/js/gulp-sass)
1+
# gulp-sass ![Build status](https://img.shields.io/travis/dlmanning/gulp-sass) [![Join the chat at https://gitter.im/dlmanning/gulp-sass](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/dlmanning/gulp-sass?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) ![Node support](https://img.shields.io/node/v/gulp-sass) ![NPM package version](https://img.shields.io/npm/v/gulp-sass?label=npm%20version)
22

33
Sass plugin for [Gulp](https://github.com/gulpjs/gulp).
44

5-
**_Before filing an issue, please make sure you have [Updated to the latest Gulp Sass](https://github.com/dlmanning/gulp-sass/wiki/Update-to-the-latest-Gulp-Sass) and have gone through our [Common Issues and Their Fixes](https://github.com/dlmanning/gulp-sass/wiki/Common-Issues-and-Their-Fixes) section._**
5+
**_Before filing an issue, please make sure you have [updated to the latest version of `gulp-sass`](https://github.com/dlmanning/gulp-sass/wiki/Update-to-the-latest-Gulp-Sass) and have gone through our [Common Issues and Their Fixes](https://github.com/dlmanning/gulp-sass/wiki/Common-Issues-and-Their-Fixes) section._**
66

7-
# Support
7+
**Migrating your existing project to version 5? Please read our (short!) [migration guide](#migrating-to-version-5).**
8+
9+
## Support
810

911
Only [Active LTS and Current releases][1] are supported.
1012

1113
[1]: https://github.com/nodejs/Release#release-schedule
1214

13-
# Install
15+
## Installation
16+
17+
To use `gulp-sass`, you must install both `gulp-sass` itself *and* a Sass compiler. `gulp-sass` supports both [Dart Sass][] and [Node Sass][], but Node Sass is [deprecated](https://sass-lang.com/blog/libsass-is-deprecated). We recommend that you use Dart Sass for new projects, and migrate Node Sass projects to Dart Sass when possible.
18+
19+
Whichever compiler you choose, it's best to install these as dev dependencies:
1420

1521
```
16-
npm install node-sass gulp-sass --save-dev
22+
npm install sass gulp-sass --save-dev
1723
```
1824

19-
# Basic Usage
25+
## Usage
26+
27+
**Note:** These examples assume you're using Gulp 4. For examples that work with Gulp 3, [check the docs for an earlier version of `gulp-sass`](https://github.com/dlmanning/gulp-sass/tree/v4.1.1).
28+
29+
`gulp-sass` runs inside of Gulp tasks. No matter what else you do with `gulp-sass`, you must first import it into your gulpfile, making sure to pass it the compiler of your choice. From there, create a Gulp task that calls either `sass()` (to asynchronously render your CSS), or `sass.sync()` (to render it synchronously). Then, export your task with the `export` keyword. We'll show some examples of how to do that.
30+
31+
**⚠️ Note:** With Dart Sass, **synchronous rendering is twice as fast as asynchronous rendering**. The Sass team is exploring ways to improve asynchronous rendering with Dart Sass, but for now you will get the best performance from `sass.sync()`
32+
33+
### Render your CSS
2034

21-
Something like this will compile your Sass files:
35+
To render your CSS with a build task, then watch your files for changes, you might write something like this.:
2236

2337
```javascript
2438
'use strict';
2539

2640
var gulp = require('gulp');
27-
var sass = require('gulp-sass');
41+
var sass = require('gulp-sass')(require('sass'));
2842

29-
sass.compiler = require('node-sass');
30-
31-
gulp.task('sass', function () {
43+
function buildStyles() {
3244
return gulp.src('./sass/**/*.scss')
3345
.pipe(sass().on('error', sass.logError))
3446
.pipe(gulp.dest('./css'));
35-
});
47+
};
3648

37-
gulp.task('sass:watch', function () {
49+
exports.buildStyles = buildStyles;
50+
exports.watch = function () {
3851
gulp.watch('./sass/**/*.scss', ['sass']);
39-
});
52+
};
4053
```
4154

42-
You can also compile synchronously, doing something like this:
43-
44-
```javascript
45-
'use strict';
46-
47-
var gulp = require('gulp');
48-
var sass = require('gulp-sass');
49-
50-
sass.compiler = require('node-sass');
55+
With synchronous rendering, that Gulp task looks like this:
5156

52-
gulp.task('sass', function () {
57+
``` javascript
58+
function buildStyles() {
5359
return gulp.src('./sass/**/*.scss')
5460
.pipe(sass.sync().on('error', sass.logError))
5561
.pipe(gulp.dest('./css'));
56-
});
57-
58-
gulp.task('sass:watch', function () {
59-
gulp.watch('./sass/**/*.scss', ['sass']);
60-
});
62+
};
6163
```
6264

63-
You can choose whether to use [Dart Sass][] or [Node Sass][] by setting the `sass.compiler` property. Node Sass will be used by default, but it's strongly recommended that you set it explicitly for forwards-compatibility in case the default ever changes.
65+
### Render with options
6466

65-
[Dart Sass]: http://sass-lang.com/dart-sass
66-
[Node Sass]: https://github.com/sass/node-sass
67+
To change the final output of your CSS, you can pass an options object to your renderer. `gulp-sass` supports [Node Sass's render options](https://github.com/sass/node-sass#options), with two unsupported exceptions:
6768

68-
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:
69+
- The `data` option, which is used by `gulp-sass` internally.
70+
- The `file` option, which has undefined behavior that may change without notice.
71+
72+
For example, to compress your CSS, you can call `sass({outputStyle: 'compressed'}`. In the context of a Gulp task, that looks like this:
6973

7074
```javascript
71-
'use strict';
75+
function buildStyles() {
76+
return gulp.src('./sass/**/*.scss')
77+
.pipe(sass({outputStyle: 'compressed'}).on('error', sass.logError))
78+
.pipe(gulp.dest('./css'));
79+
};
7280

73-
var Fiber = require('fibers');
74-
var gulp = require('gulp');
75-
var sass = require('gulp-sass');
81+
exports.buildStyles = buildStyles;
82+
```
7683

77-
sass.compiler = require('sass');
84+
Or this for synchronous rendering:
7885

79-
gulp.task('sass', function () {
86+
```javascript
87+
function buildStyles() {
8088
return gulp.src('./sass/**/*.scss')
81-
.pipe(sass({fiber: Fiber}).on('error', sass.logError))
89+
.pipe(sass.sync({outputStyle: 'compressed'}).on('error', sass.logError))
8290
.pipe(gulp.dest('./css'));
83-
});
91+
};
8492

85-
gulp.task('sass:watch', function () {
86-
gulp.watch('./sass/**/*.scss', ['sass']);
87-
});
93+
exports.buildStyles = buildStyles;
8894
```
8995

90-
## Options
91-
92-
Pass in options just like you would for [Node Sass](https://github.com/sass/node-sass#options); they will be passed along just as if you were using Node Sass. Except for the `data` option which is used by gulp-sass internally. Using the `file` option is also unsupported and results in undefined behaviour that may change without notice.
96+
### Include a source map
9397

94-
For example:
98+
`gulp-sass` can be used in tandem with [`gulp-sourcemaps`](https://github.com/floridoo/gulp-sourcemaps) to generate source maps for the Sass-to-CSS compilation. You will need to initialize `gulp-sourcemaps` _before_ running `gulp-sass`, and write the source maps after.
9599

96100
```javascript
97-
gulp.task('sass', function () {
98-
return gulp.src('./sass/**/*.scss')
99-
.pipe(sass({outputStyle: 'compressed'}).on('error', sass.logError))
100-
.pipe(gulp.dest('./css'));
101-
});
101+
var sourcemaps = require('gulp-sourcemaps');
102+
103+
function buildStyles() {
104+
return gulp.src('./sass/**/*.scss')
105+
.pipe(sourcemaps.init())
106+
.pipe(sass().on('error', sass.logError))
107+
.pipe(sourcemaps.write())
108+
.pipe(gulp.dest('./css'));
109+
}
110+
111+
exports.buildStyles = buildStyles;
102112
```
103113

104-
Or this for synchronous code:
114+
By default, `gulp-sourcemaps` writes the source maps inline, in the compiled CSS files. To write them to a separate file, specify a path relative to the `gulp.dest()` destination in the `sourcemaps.write()` function.
105115

106116
```javascript
107-
gulp.task('sass', function () {
108-
return gulp.src('./sass/**/*.scss')
109-
.pipe(sass.sync({outputStyle: 'compressed'}).on('error', sass.logError))
110-
.pipe(gulp.dest('./css'));
111-
});
117+
var sourcemaps = require('gulp-sourcemaps');
118+
119+
function buildStyles() {
120+
return gulp.src('./sass/**/*.scss')
121+
.pipe(sourcemaps.init())
122+
.pipe(sass().on('error', sass.logError))
123+
.pipe(sourcemaps.write('./maps'))
124+
.pipe(gulp.dest('./css'));
125+
};
126+
127+
exports.buildStyles = buildStyles;
112128
```
113129

114-
## Source Maps
130+
<h2 id="migrating-to-version-5">Migrating to version 5</h2>
115131

116-
`gulp-sass` can be used in tandem with [gulp-sourcemaps](https://github.com/floridoo/gulp-sourcemaps) to generate source maps for the Sass to CSS compilation. You will need to initialize [gulp-sourcemaps](https://github.com/floridoo/gulp-sourcemaps) prior to running `gulp-sass` and write the source maps after.
132+
`gulp-sass` version 5 requires Node 12 or later, and introduces some breaking changes. Additionally, changes in Node itself mean that we should no longer use Node fibers to speed up asynchronous rendering with Dart Sass.
117133

118-
```javascript
119-
var sourcemaps = require('gulp-sourcemaps');
134+
### Setting a Sass compiler
120135

121-
gulp.task('sass', function () {
122-
return gulp.src('./sass/**/*.scss')
123-
.pipe(sourcemaps.init())
124-
.pipe(sass().on('error', sass.logError))
125-
.pipe(sourcemaps.write())
126-
.pipe(gulp.dest('./css'));
127-
});
136+
As of version 5, `gulp-sass` _does not include a default Sass compiler_, so you must install one (either `node-sass` or `sass`) along with `gulp-sass`.
137+
138+
```
139+
npm install sass gulp-sass --save-dev
128140
```
129141

130-
By default, [gulp-sourcemaps](https://github.com/floridoo/gulp-sourcemaps) writes the source maps inline in the compiled CSS files. To write them to a separate file, specify a path relative to the `gulp.dest()` destination in the `sourcemaps.write()` function.
142+
Then, you must explicitly set that compiler in your gulpfille. Instead of setting a `compiler` prop on the `gulp-sass` instance, you pass the compiler into a function call when instantiating `gulp-sass`.
131143

132-
```javascript
133-
var sourcemaps = require('gulp-sourcemaps');
134-
gulp.task('sass', function () {
135-
return gulp.src('./sass/**/*.scss')
136-
.pipe(sourcemaps.init())
137-
.pipe(sass().on('error', sass.logError))
138-
.pipe(sourcemaps.write('./maps'))
139-
.pipe(gulp.dest('./css'));
140-
});
144+
These changes look something like this:
145+
146+
``` diff
147+
- var sass = require('gulp-sass'));
148+
- var compiler = require('sass');
149+
- sass.compiler = compiler;
150+
+ var sass = require('gulp-sass')(require('sass'));
141151
```
142152

143-
# Issues
153+
### What about fibers?
144154

145-
`gulp-sass` is a very light-weight wrapper around either [Dart Sass][] or [Node Sass][] (which in turn is a Node binding for [LibSass][]). Because of this, the issue you're having likely isn't a `gulp-sass` issue, but an issue with one those projects or with [Sass][] as a whole.
155+
We used to recommend Node fibers as a way to speed up asynchronous rendering with Dart Sass. Unfortunately, [Node fibers are discontinued](https://sass-lang.com/blog/node-fibers-discontinued). The Sass team is exploring its optons for future performance improvements, but for now you will get the best performance from `sass.sync()`.
146156

147-
[LibSass]: https://sass-lang.com/libsass
148-
[Sass]: https://sass-lang.com
157+
## Issues
158+
159+
`gulp-sass` is a light-weight wrapper around either [Dart Sass][] or [Node Sass][] (which in turn is a Node binding for [LibSass][]. Because of this, the issue you're having likely isn't a `gulp-sass` issue, but an issue with one those projects or with [Sass][] as a whole.
149160

150161
If you have a feature request/question how Sass works/concerns on how your Sass gets compiled/errors in your compiling, it's likely a Dart Sass or LibSass issue and you should file your issue with one of those projects.
151162

152163
If you're having problems with the options you're passing in, it's likely a Dart Sass or Node Sass issue and you should file your issue with one of those projects.
153164

154165
We may, in the course of resolving issues, direct you to one of these other projects. If we do so, please follow up by searching that project's issue queue (both open and closed) for your problem and, if it doesn't exist, filing an issue with them.
166+
167+
[Dart Sass]: http://sass-lang.com/dart-sass
168+
[LibSass]: https://sass-lang.com/libsass
169+
[Node Sass]: https://github.com/sass/node-sass
170+
[Sass]: https://sass-lang.com

‎index.js

+36-24
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@ const chalk = require('chalk');
22
const PluginError = require('plugin-error');
33
const replaceExtension = require('replace-ext');
44
const stripAnsi = require('strip-ansi');
5-
const through = require('through2');
5+
const transfob = require('transfob');
66
const clonedeep = require('lodash/cloneDeep');
77
const path = require('path');
88
const applySourceMap = require('vinyl-sourcemaps-apply');
99

1010
const PLUGIN_NAME = 'gulp-sass';
1111

12-
//////////////////////////////
12+
/// ///////////////////////////
1313
// Main Gulp Sass function
14-
//////////////////////////////
15-
const gulpSass = (options, sync) => through.obj((file, enc, cb) => { // eslint-disable-line consistent-return
14+
/// ///////////////////////////
15+
const gulpSass = (options, sync) => transfob((file, enc, cb) => { // eslint-disable-line consistent-return
1616
if (file.isNull()) {
1717
return cb(null, file);
1818
}
@@ -59,9 +59,9 @@ const gulpSass = (options, sync) => through.obj((file, enc, cb) => { // eslint-d
5959
opts.sourceMapContents = true;
6060
}
6161

62-
//////////////////////////////
62+
/// ///////////////////////////
6363
// Handles returning the file to the stream
64-
//////////////////////////////
64+
/// ///////////////////////////
6565
const filePush = (sassObj) => {
6666
let sassMap;
6767
let sassMapFile;
@@ -88,7 +88,7 @@ const gulpSass = (options, sync) => through.obj((file, enc, cb) => { // eslint-d
8888
}
8989

9090
// Remove 'stdin' from souces and replace with filenames!
91-
sassMap.sources = sassMap.sources.filter(src => src !== 'stdin' && src);
91+
sassMap.sources = sassMap.sources.filter((src) => src !== 'stdin' && src);
9292

9393
// Replace the map file with the original file name (but new extension)
9494
sassMap.file = replaceExtension(sassFileSrc, '.css');
@@ -106,9 +106,9 @@ const gulpSass = (options, sync) => through.obj((file, enc, cb) => { // eslint-d
106106
cb(null, file);
107107
};
108108

109-
//////////////////////////////
109+
/// ///////////////////////////
110110
// Handles error message
111-
//////////////////////////////
111+
/// ///////////////////////////
112112
const errorM = (error) => {
113113
const filePath = (error.file === 'stdin' ? file.path : error.file) || file.path;
114114
const relativePath = path.relative(process.cwd(), filePath);
@@ -123,9 +123,9 @@ const gulpSass = (options, sync) => through.obj((file, enc, cb) => { // eslint-d
123123
};
124124

125125
if (sync !== true) {
126-
//////////////////////////////
126+
/// ///////////////////////////
127127
// Async Sass render
128-
//////////////////////////////
128+
/// ///////////////////////////
129129
const callback = (error, obj) => { // eslint-disable-line consistent-return
130130
if (error) {
131131
return errorM(error);
@@ -135,9 +135,9 @@ const gulpSass = (options, sync) => through.obj((file, enc, cb) => { // eslint-d
135135

136136
gulpSass.compiler.render(opts, callback);
137137
} else {
138-
//////////////////////////////
138+
/// ///////////////////////////
139139
// Sync Sass render
140-
//////////////////////////////
140+
/// ///////////////////////////
141141
try {
142142
filePush(gulpSass.compiler.renderSync(opts));
143143
} catch (error) {
@@ -146,23 +146,35 @@ const gulpSass = (options, sync) => through.obj((file, enc, cb) => { // eslint-d
146146
}
147147
});
148148

149-
//////////////////////////////
149+
/// ///////////////////////////
150150
// Sync Sass render
151-
//////////////////////////////
152-
gulpSass.sync = options => gulpSass(options, true);
151+
/// ///////////////////////////
152+
gulpSass.sync = (options) => gulpSass(options, true);
153153

154-
//////////////////////////////
154+
/// ///////////////////////////
155155
// Log errors nicely
156-
//////////////////////////////
156+
/// ///////////////////////////
157157
gulpSass.logError = function logError(error) {
158158
const message = new PluginError('sass', error.messageFormatted).toString();
159159
process.stderr.write(`${message}\n`);
160160
this.emit('end');
161161
};
162162

163-
//////////////////////////////
164-
// Store compiler in a prop
165-
//////////////////////////////
166-
gulpSass.compiler = require('node-sass');
167-
168-
module.exports = gulpSass;
163+
module.exports = (compiler) => {
164+
if (!compiler || !compiler.render) {
165+
const message = new PluginError(
166+
PLUGIN_NAME,
167+
'\n'
168+
+ 'gulp-sass 5 does not have a default Sass compiler; please set one yourself.\n'
169+
+ 'Both the `sass` and `node-sass` packages are permitted.\n'
170+
171+
+ 'For example, in your gulpfile:\n\n'
172+
+ ' var sass = require(\'gulp-sass\')(require(\'sass\'));\n',
173+
{ showProperties: false },
174+
).toString();
175+
process.stderr.write(`${message}\n`);
176+
process.exit(1);
177+
}
178+
gulpSass.compiler = compiler;
179+
return gulpSass;
180+
};

‎package.json

+23-22
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{
22
"name": "gulp-sass",
3-
"version": "4.1.1",
3+
"version": "5.0.0",
44
"description": "Gulp plugin for sass",
55
"main": "index.js",
66
"engines": {
7-
"node": ">=6"
7+
"node": ">=12"
88
},
99
"scripts": {
10-
"test": "./node_modules/.bin/mocha test"
10+
"test": "mocha test"
1111
},
1212
"repository": {
1313
"type": "git",
@@ -24,28 +24,29 @@
2424
"url": "https://github.com/dlmanning/gulp-sass/issues"
2525
},
2626
"dependencies": {
27-
"chalk": "^2.3.0",
27+
"chalk": "^4.1.1",
2828
"lodash": "^4.17.20",
29-
"node-sass": "^4.8.3",
3029
"plugin-error": "^1.0.1",
31-
"replace-ext": "^1.0.0",
32-
"strip-ansi": "^4.0.0",
33-
"through2": "^2.0.0",
34-
"vinyl-sourcemaps-apply": "^0.2.0"
30+
"replace-ext": "^2.0.0",
31+
"strip-ansi": "^6.0.0",
32+
"transfob": "^1.0.0",
33+
"vinyl-sourcemaps-apply": "^0.2.1"
3534
},
3635
"devDependencies": {
37-
"autoprefixer": "^8.1.0",
38-
"eslint": "^4.18.2",
39-
"eslint-config-airbnb-base": "^12.1.0",
40-
"eslint-plugin-import": "^2.9.0",
41-
"globule": "^1.0.0",
42-
"gulp": "^3.8.11",
43-
"gulp-postcss": "^7.0.1",
44-
"gulp-sourcemaps": "^2.6.4",
45-
"gulp-tap": "^0.1.3",
46-
"mocha": "^5.0.4",
47-
"rimraf": "^2.4.3",
48-
"should": "^13.2.1",
49-
"vinyl": "^2.1.0"
36+
"autoprefixer": "^10.2.6",
37+
"eslint": "^7.28.0",
38+
"eslint-config-airbnb-base": "^14.2.1",
39+
"eslint-plugin-import": "^2.23.4",
40+
"globule": "^1.3.2",
41+
"gulp": "^4.0.2",
42+
"gulp-postcss": "^9.0.0",
43+
"gulp-sourcemaps": "^3.0.0",
44+
"gulp-tap": "^2.0.0",
45+
"mocha": "^9.0.0",
46+
"node-sass": "^6.0.0",
47+
"postcss": "^8.3.4",
48+
"rimraf": "^3.0.2",
49+
"should": "^13.2.3",
50+
"vinyl": "^2.2.1"
5051
}
5152
}

‎test/main.js

+27-26
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ const should = require('should');
22
const Vinyl = require('vinyl');
33
const path = require('path');
44
const fs = require('fs');
5-
const sass = require('../index');
65
const rimraf = require('rimraf');
76
const gulp = require('gulp');
87
const sourcemaps = require('gulp-sourcemaps');
@@ -11,6 +10,8 @@ const autoprefixer = require('autoprefixer');
1110
const tap = require('gulp-tap');
1211
const globule = require('globule');
1312

13+
const sass = require('../index')(require('node-sass'));
14+
1415
const createVinyl = (filename, contents) => {
1516
const base = path.join(__dirname, 'scss');
1617
const filePath = path.join(base, filename);
@@ -23,7 +24,7 @@ const createVinyl = (filename, contents) => {
2324
});
2425
};
2526

26-
const normaliseEOL = str => str.toString('utf8').replace(/\r\n/g, '\n');
27+
const normaliseEOL = (str) => str.toString('utf8').replace(/\r\n/g, '\n');
2728

2829
describe('test helpers', () => {
2930
it('should normalise EOL', (done) => {
@@ -224,14 +225,14 @@ describe('gulp-sass -- async compile', () => {
224225
it('should work with gulp-sourcemaps', (done) => {
225226
const sassFile = createVinyl('inheritance.scss');
226227

227-
sassFile.sourceMap = '{' +
228-
'"version": 3,' +
229-
'"file": "scss/subdir/multilevelimport.scss",' +
230-
'"names": [],' +
231-
'"mappings": "",' +
232-
'"sources": [ "scss/subdir/multilevelimport.scss" ],' +
233-
'"sourcesContent": [ "@import ../inheritance;" ]' +
234-
'}';
228+
sassFile.sourceMap = '{'
229+
+ '"version": 3,'
230+
+ '"file": "scss/subdir/multilevelimport.scss",'
231+
+ '"names": [],'
232+
+ '"mappings": "",'
233+
+ '"sources": [ "scss/subdir/multilevelimport.scss" ],'
234+
+ '"sourcesContent": [ "@import ../inheritance;" ]'
235+
+ '}';
235236

236237
// Expected sources are relative to file.base
237238
const expectedSources = [
@@ -425,14 +426,14 @@ describe('gulp-sass -- sync compile', () => {
425426
'includes/_dogs.sass',
426427
];
427428

428-
sassFile.sourceMap = '{' +
429-
'"version": 3,' +
430-
'"file": "scss/subdir/multilevelimport.scss",' +
431-
'"names": [],' +
432-
'"mappings": "",' +
433-
'"sources": [ "scss/subdir/multilevelimport.scss" ],' +
434-
'"sourcesContent": [ "@import ../inheritance;" ]' +
435-
'}';
429+
sassFile.sourceMap = '{'
430+
+ '"version": 3,'
431+
+ '"file": "scss/subdir/multilevelimport.scss",'
432+
+ '"names": [],'
433+
+ '"mappings": "",'
434+
+ '"sources": [ "scss/subdir/multilevelimport.scss" ],'
435+
+ '"sourcesContent": [ "@import ../inheritance;" ]'
436+
+ '}';
436437

437438
const stream = sass.sync();
438439
stream.on('data', (cssFile) => {
@@ -469,8 +470,8 @@ describe('gulp-sass -- sync compile', () => {
469470
.pipe(tap((file) => {
470471
should.exist(file.sourceMap);
471472
file.sourceMap.sources.should.eql(expectedSourcesAfter);
472-
}))
473-
.on('end', done);
473+
}));
474+
done();
474475
});
475476

476477
it('should work with gulp-sourcemaps and a globbed source', (done) => {
@@ -491,8 +492,8 @@ describe('gulp-sass -- sync compile', () => {
491492
const actual = normaliseEOL(file.sourceMap.sourcesContent[0]);
492493
const expected = normaliseEOL(filesContent[path.normalize(file.sourceMap.sources[0])]);
493494
actual.should.eql(expected);
494-
}))
495-
.on('end', done);
495+
}));
496+
done();
496497
});
497498

498499
it('should work with gulp-sourcemaps and autoprefixer with different file.base', (done) => {
@@ -519,8 +520,8 @@ describe('gulp-sass -- sync compile', () => {
519520
.pipe(tap((file) => {
520521
should.exist(file.sourceMap);
521522
file.sourceMap.sources.should.eql(expectedSourcesAfter);
522-
}))
523-
.on('end', done);
523+
}));
524+
done();
524525
});
525526

526527
it('should work with empty files', (done) => {
@@ -533,7 +534,7 @@ describe('gulp-sass -- sync compile', () => {
533534
} catch (e) {
534535
should.fail(false, true, 'Empty file was produced');
535536
}
536-
}))
537-
.on('end', done);
537+
}));
538+
done();
538539
});
539540
});

0 commit comments

Comments
 (0)
Please sign in to comment.