1.1.1 • Published 10 years ago

gulp-less-dependents v1.1.1

Weekly downloads
173
License
MIT
Repository
github
Last release
10 years ago

gulp-less-dependents Build Status

Collect dependents of less files

Gives you a chance to recompile less files on modification of a file which those files are depending on.

Install

npm install gulp-less-dependents

Usage

var gulp = require('gulp');
var watch = require('gulp-watch');
var lessDependents = require('gulp-less-dependents');
var less = require('gulp-less');

gulp.task('less', function() {
    gulp.src('./less/**/*.less')
        .pipe(watch('./less/**/*.less'))
        .pipe(lessDependents())
        .pipe(less())
        .pipe(gulp.dest('./public/css'));
});

lessDependents() analyzes dependencies of files passed from the upstream, and passes files that are (1) passed from the upstream, or (2) depending on files from the upstream. For the files of (2), they must be once a target of analysis earlier; it means that files of (2) are included in those of (1) for the first time. In the example above shows that src() gives files of (1), and files of (2) are triggered by watch() after the first run.

If you wish to exclude the depended files from compilation but want to watch them for recompilation of the dependents, use gulp-filter for the exclusion. For example, if you have depended files in ./less/includes, the task may look like the following.

var gulp = require('gulp');
var watch = require('gulp-watch');
var gulpFilter = require('gulp-filter');
var lessDependents = require('gulp-less-dependents');
var less = require('gulp-less');

gulp.task('less', function() {
    gulp.src('./less/**/*.less')
        .pipe(watch('./less/**/*.less'))
        .pipe(lessDependents())
        .pipe(gulpFilter([ '*', '!less/includes/*.less' ]))
        .pipe(less())
        .pipe(gulp.dest('./public/css'));
});

API

lessDependents(options)

options

This object is passed to less.Parser internally used for dependency analysis.

License

MIT (c) INA Lintaro (tarao.gnn@gmail.com)