gulp-better-sass-inheritance
Version:
Recompile only changed sass/scss files and their dependencies (extended, included or imported)
55 lines (37 loc) • 1.85 kB
Markdown
# gulp-better-sass-inheritance
[](https://travis-ci.org/Jeff2Ma/gulp-better-sass-inheritance)
[](https://ci.appveyor.com/project/Jeff2Ma/gulp-better-sass-inheritance)
[](https://www.npmjs.com/package/gulp-better-sass-inheritance)
> Recompile only changed sass/scss files and their dependencies (extended, included or imported).
Based on [gulp-sass-inheritance-plus](https://www.npmjs.com/package/gulp-sass-inheritance-plus).
Solve the bugs in based plugin and make better performace.
NPM Page: [https://www.npmjs.com/package/gulp-better-sass-inheritance](https://www.npmjs.com/package/gulp-better-sass-inheritance)
## Usage
### Install
```bash
npm i gulp-better-sass-inheritance -D
```
### Gulp file
Suggest to work with [gulp-sass](https://www.npmjs.com/package/gulp-sass).
```javascript
var gulp = require('gulp');
var sassInheritance = require('gulp-better-sass-inheritance');
var sass = require('gulp-sass');
var cached = require('gulp-cached');
var gulpif = require('gulp-if');
gulp.task('sass', function() {
return gulp.src('src/styles/**/*.scss')
//filter out unchanged scss files, only works when watching
.pipe(gulpif(global.isWatching, cached('sass')))
//find files that depend on the files that have changed
.pipe(sassInheritance({base: 'src/styles/'}))
//process scss files
.pipe(sass())
//save all the files
.pipe(gulp.dest('dist'));
});
gulp.task('watch', ['sass', 'other-task'], function() {
global.isWatching = true;
//your watch functions...
});
```