Bachir Soussi Chiadmi ac58a24f5c added bower, gulp | 7 年之前 | |
---|---|---|
.. | ||
dest | 7 年之前 | |
.editorconfig | 7 年之前 | |
.eslintrc | 7 年之前 | |
.npmignore | 7 年之前 | |
.travis.yml | 7 年之前 | |
CHANGELOG.md | 7 年之前 | |
CONTRIBUTING.md | 7 年之前 | |
LICENSE | 7 年之前 | |
README.md | 7 年之前 | |
index.js | 7 年之前 | |
package.json | 7 年之前 | |
test.js | 7 年之前 | |
test.scss | 7 年之前 |
Sass plugin for Gulp.
Before filing an issue, please make sure you have Updated to the latest Gulp Sass and have gone through our Common Issues and Their Fixes section.
npm install gulp-sass --save-dev
Something like this will compile your Sass files:
'use strict';
var gulp = require('gulp');
var sass = require('gulp-sass');
gulp.task('sass', function () {
return gulp.src('./sass/**/*.scss')
.pipe(sass().on('error', sass.logError))
.pipe(gulp.dest('./css'));
});
gulp.task('sass:watch', function () {
gulp.watch('./sass/**/*.scss', ['sass']);
});
You can also compile synchronously, doing something like this:
'use strict';
var gulp = require('gulp');
var sass = require('gulp-sass');
gulp.task('sass', function () {
return gulp.src('./sass/**/*.scss')
.pipe(sass.sync().on('error', sass.logError))
.pipe(gulp.dest('./css'));
});
gulp.task('sass:watch', function () {
gulp.watch('./sass/**/*.scss', ['sass']);
});
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', function () {
return gulp.src('./sass/**/*.scss')
.pipe(sass({outputStyle: 'compressed'}).on('error', sass.logError))
.pipe(gulp.dest('./css'));
});
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.
var sourcemaps = require('gulp-sourcemaps');
gulp.task('sass', function () {
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.
var sourcemaps = require('gulp-sourcemaps');
gulp.task('sass', function () {
return gulp.src('./sass/**/*.scss')
.pipe(sourcemaps.init())
.pipe(sass().on('error', sass.logError))
.pipe(sourcemaps.write('./maps'))
.pipe(gulp.dest('./css'));
});
gulp-sass
is a very light-weight wrapper around node-sass
, which in turn is a Node binding for libsass
, which in turn is a port of Sass
. Because of this, the issue you're having likely isn't a gulp-sass
issue, but an issue with one of those three projects.
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 libsass
or Sass
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 node-sass
or libsass
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.