gulp-sass/README.md

84 lines
2.7 KiB
Markdown
Raw Normal View History

2014-01-19 09:50:19 +01:00
[![Build Status](https://travis-ci.org/dlmanning/gulp-sass.png?branch=master)](https://travis-ci.org/dlmanning/gulp-sass)
2013-08-31 23:01:20 +02:00
gulp-sass
=========
2013-09-01 06:54:25 +02:00
SASS plugin for [gulp](https://github.com/wearefractal/gulp).
#Install
```
npm install gulp-sass
```
#Basic Usage
2013-09-01 06:54:25 +02:00
Something like this:
```javascript
var gulp = require('gulp');
var sass = require('gulp-sass')
gulp.task('sass', function () {
2013-12-04 18:36:46 +01:00
gulp.src('./scss/*.scss')
2013-09-01 06:54:25 +02:00
.pipe(sass())
.pipe(gulp.dest('./css'));
});
```
2014-01-13 07:27:45 +01:00
Options passed as a hash into `sass()` will be passed along to [`node-sass`](https://github.com/andrew/node-sass)
## gulp-sass specific options
#### `errLogToConsole: true`
2014-01-13 07:27:45 +01:00
If you pass `errLogToConsole: true` into the options hash, sass errors will be logged to the console instead of generating a `gutil.PluginError` object. Use this option with `gulp.watch` to keep gulp from stopping every time you mess up your sass.
2013-09-01 06:54:25 +02:00
#### `onSuccess: callback`
Pass in your own callback to be called upon successful compilaton by node-sass. The callback has the form `callback(css)`, and is passed the compiled css as a string. Note: This *does not* prevent gulp-sass's default behavior of writing the output css file.
#### `onError: callback`
Pass in your own callback to be called upon a sass error from node-sass. The callback has the form `callback(err)`, where err is the error string generated by libsass. Note: this *does* prevent an actual `gulpPluginError` object from being created.
#### `sync: true`
If you pass `sync: true` into the options hash, sass.renderSync will be called, instead of sass.render. This should help when memory and/or cpu usage is getting very high when rendering many and/or big files.
2014-02-11 06:01:45 +01:00
## Source Maps
2014-02-22 01:08:13 +01:00
gulp-sass now generates *inline* source maps if you pass `sourceComments: 'map'` as an option. Note that gulp-sass won't actually do anything when passing `sourceMap: filepath`. Enjoy your source maps!
2014-02-11 06:01:45 +01:00
NB: For those wondering, inline source maps are stuck onto the end of the css file instead of being in a separate map file. In this case, the original source contents are included as well, so you don't have to make sure your scss files are servable.
#Imports and Partials
2014-01-22 21:52:04 +01:00
gulp-sass now automatically passes along the directory of every scss file it parses as an include path for node-sass. This means that as long as you specify your includes relative to path of your scss file, everything will just work.
scss/includes/_settings.scss:
```scss
$blue: #3bbfce;
$margin: 16px;
```
scss/style.scss:
```scss
2014-01-22 21:52:04 +01:00
@import "includes/settings";
.content-navigation {
border-color: $blue;
color:
darken($blue, 9%);
}
.border {
padding: $margin / 2;
margin: $margin / 2;
border-color: $blue;
}
```