gulp-watch-less2

2.0.4 • Public • Published

gulp-watch-less2 NPM version Build Status Dependency Status

Gulp plugin for watching .less files and their @imports, based on chokidar

Install

$ npm i -D gulp-watch-less2

Protip: until gulpjs 4.0 is released, you can use gulp-plumber to avoid watch process be terminated by errors.

Usage

var gulp = require('gulp');
var watchLess = require('gulp-watch-less2');
var less = require('gulp-less');
var lessGlobs = 'less/main-*.less';
gulp.task('default', function () {
  return gulp.src(lessGlobs)
    .pipe(watchLess(lessGlobs, {verbose: true}))
    .pipe(less())
    .pipe(gulp.dest('dist'));
});

Important Note

  • Strongly recommand using specific glob to filter import files. E.g. main-*.less to ignore import files which filename is not start with main-.

The following actions will trigger recompile main-*.less.

  • Add/Reorder/Remove @import statement(s) in main-*.less
  • Change code of file imported in main-*.less
  • Change code of main-*.less

API

GulpWatchLess(glob, [options, callback])

Returns pass-through stream, that will emit vinyl files (with additional event property) that corresponds to event on file-system.

glob

Glob can be a node-glob string or array of strings.

Options

See documentation on chokidar task

options.less

Type: object
Default: {}

Optional options passed through to the less.Parser instance.

Callback function(events, done)

See documentation on chokidar task

License

MIT © John Xiao

Package Sidebar

Install

npm i gulp-watch-less2

Weekly Downloads

179

Version

2.0.4

License

MIT

Last publish

Collaborators

  • bammoo