Go to file
selfisekai 06bd869e5d release 4.2.0 2020-11-06 14:46:25 +01:00
test made dart sass default 2020-11-06 12:24:25 +01:00
.editorconfig Added linting 2015-03-24 05:32:12 -05:00
.eslintrc Adopt airbnb eslint preset 2018-03-24 12:55:37 +11:00
.gitignore Add node_modules to gitignore 2013-12-14 18:23:28 -08:00
.gitlab-ci.yml add gitlab ci 2020-11-06 13:59:31 +01:00
.npmignore Version 1.3.1 2015-01-13 20:49:16 -08:00
.travis.yml Drop support for non-active lts and current release 2018-03-24 12:55:07 +11:00
CHANGELOG.md release 4.2.0 2020-11-06 14:46:25 +01:00
CONTRIBUTING.md Continue loading Node Sass by default 2018-10-16 17:57:46 +10:00
LICENSE this is a fork 🔥 2020-11-05 23:40:12 +01:00
README.md this is a fork 🔥 2020-11-05 23:40:12 +01:00
appveyor.yml Fix node versions in appveyor.yml 2018-04-05 21:08:06 +10:00
index.d.ts typescript typedefs 2020-11-06 12:24:32 +01:00
index.js made dart sass default 2020-11-06 12:24:25 +01:00
package.json release 4.2.0 2020-11-06 14:46:25 +01:00
yarn.lock typescript typedefs 2020-11-06 12:24:32 +01:00

README.md

gulp-sass

Sass plugin for Gulp.

This is a fork of David Manning's Gulp Sass.

Support

Only Active LTS and Current releases are supported.

Install

yarn add --dev sass @selfisekai/gulp-sass

Basic Usage

Something like this will compile your Sass files:

'use strict';

const gulp = require('gulp');
const sass = require('@selfisekai/gulp-sass');

sass.compiler = require('sass');

gulp.task('sass', () => {
  return gulp.src('./sass/**/*.scss')
    .pipe(sass().on('error', sass.logError))
    .pipe(gulp.dest('./css'));
});

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

You can also compile synchronously, doing something like this:

'use strict';

const gulp = require('gulp');
const sass = require('@selfisekai/gulp-sass');

sass.compiler = require('sass');

gulp.task('sass', () => {
  return gulp.src('./sass/**/*.scss')
    .pipe(sass.sync().on('error', sass.logError))
    .pipe(gulp.dest('./css'));
});

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

You can choose whether to use Dart Sass or Node Sass by setting the sass.compiler property. Dart 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.

Compiler Maintained No installation problems
Dart Sass yes yes
Node Sass no no

Note that when using Dart Sass, synchronous compilation is twice as fast as asynchronous compilation by default, due to the overhead of asynchronous callbacks.

Options

Pass in options just like you would for Node Sass; 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.

For example:

gulp.task('sass', () => {
 return gulp.src('./sass/**/*.scss')
   .pipe(sass({outputStyle: 'compressed'}).on('error', sass.logError))
   .pipe(gulp.dest('./css'));
});

Or this for synchronous code:

gulp.task('sass', () => {
 return gulp.src('./sass/**/*.scss')
   .pipe(sass.sync({outputStyle: 'compressed'}).on('error', sass.logError))
   .pipe(gulp.dest('./css'));
});

Source Maps

gulp-sass can be used in tandem with gulp-sourcemaps to generate source maps for the Sass to CSS compilation. You will need to initialize gulp-sourcemaps prior to running gulp-sass and write the source maps after.

const sourcemaps = require('gulp-sourcemaps');

gulp.task('sass', () => {
 return gulp.src('./sass/**/*.scss')
  .pipe(sourcemaps.init())
  .pipe(sass().on('error', sass.logError))
  .pipe(sourcemaps.write())
  .pipe(gulp.dest('./css'));
});

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.

const sourcemaps = require('gulp-sourcemaps');
gulp.task('sass', () => {
 return gulp.src('./sass/**/*.scss')
  .pipe(sourcemaps.init())
  .pipe(sass().on('error', sass.logError))
  .pipe(sourcemaps.write('./maps'))
  .pipe(gulp.dest('./css'));
});

Issues

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.

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.

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.

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.