npm

npm’s 2019 JavaScript ecosystem survey analysis is now available!Get your copy here »

less-stream

0.1.4 • Public • Published

less-stream

Streaming less compiler, with support for sourcemaps. Uses less.Parser.parse() to correctly interpret global and modify vars.

installation

Add to your devDependencies:

  "dependencies": {...},
  "devDependencies": {
    "less-stream": "~0.1.4"
  },
  ...

or install directly:

npm install --save-dev less-stream

Then import in your build script:

var less = require('less-stream');

usage

As a simple streaming compiler:

var less = require('less-stream'),
  fs = require('fs');
 
fs.createReadStream('path/to/less/src')
  .pipe(less())
  .pipe(fs.createWriteStream('path/to/css'));

With streaming build tools like gulp:

var gulp = require('gulp'),
  less = require('less-stream'),  // gulp-less uses less.render() & can't support global/modify vars
  sourcemaps = require('gulp-sourcemaps');
 
// Basic compile
gulp.task('less', function () {
  return gulp.src('path/to/less/*.less')
    .pipe(less())
    .pipe(gulp.dest('path/to/css/'));
});
 
// With sourcemaps
gulp.task('less:sourcemap', function () {
  return gulp.src('path/to/less/*.less')
    .pipe(sourcemaps.init())
    .pipe(less())
    .pipe(sourcemaps.write())
    .pipe(gulp.dest('path/to/css/'));
});

api

less(options)

Accepts the same options hash as the lessc compiler, and returns a Writable stream.

install

npm i less-stream

Downloadsweekly downloads

9

version

0.1.4

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability