# gulp-sources-less

> A LESS plugin for Gulp based on the excellent gulp-less with added support for vinyl-sources

Latest version **1.0.1** (published 2015-06-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install gulp-sources-less
pnpm add gulp-sources-less
yarn add gulp-sources-less
bun add gulp-sources-less
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2015-06-20 |
| First published | 2015-04-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 7 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | meandmycode |
| Keywords | gulpplugin, gulp, less |

## Links

- npm: https://www.npmjs.com/package/gulp-sources-less
- Repository: https://github.com/meandmycode/gulp-sources-less
- Issues: https://github.com/meandmycode/gulp-sources-less/issues
- npm.io page: https://npm.io/package/gulp-sources-less

## Dependencies (7)

- [less](https://npm.io/package/less.md) ^2.5.1
- [accord](https://npm.io/package/accord.md) ^0.19.0
- [through2](https://npm.io/package/through2.md) ^2.0.0
- [gulp-util](https://npm.io/package/gulp-util.md) ^3.0.5
- [object-assign](https://npm.io/package/object-assign.md) ^3.0.0
- [vinyl-sources](https://npm.io/package/vinyl-sources.md) ^1.0.1
- [vinyl-sourcemaps-apply](https://npm.io/package/vinyl-sourcemaps-apply.md) ^0.1.4

## Recent versions

- 1.0.1 (latest) — 2015-06-20
- 1.0.0 — 2015-06-01
- 0.1.4 — 2015-04-19
- 0.1.3 — 2015-04-12
- 0.1.2 — 2015-04-05
- 0.1.1 — 2015-04-05
- 0.1.0 — 2015-04-05

## README

gulp-sources-less
=========

A LESS plugin for Gulp based on the excellent [gulp-less](https://github.com/plus3network/gulp-less) with added support for [vinyl-sources](https://github.com/meandmycode/vinyl-sources)

[![NPM Version](https://img.shields.io/npm/v/gulp-sources-less.svg)](https://www.npmjs.com/package/gulp-sources-less)
[![Build Status](https://img.shields.io/travis/meandmycode/gulp-sources-less.svg)](https://travis-ci.org/meandmycode/gulp-sources-less)
[![Coveralls Status](https://coveralls.io/repos/meandmycode/gulp-sources-less/badge.png)](https://coveralls.io/r/meandmycode/gulp-sources-less)
[![Dependency Status](https://david-dm.org/meandmycode/gulp-sources-less.png?theme=shields.io)](https://david-dm.org/meandmycode/gulp-sources-less)

## Installation

```
npm install gulp-sources-less
```

## Basic Usage

```js
var less = require('gulp-sources-less');
var path = require('path');

gulp.task('less', function () {
  return gulp.src('./less/**/*.less')
    .pipe(less({
      paths: [ path.join(__dirname, 'less', 'includes') ]
    }))
    .pipe(gulp.dest('./public/css'));
});
```

## Options

The options you can use [can be found here](http://lesscss.org/#using-less-configuration). Below is a list of valid options as of the time of writing:

- `paths`: Array of paths to be used for `@import` directives
- `plugins`: Array of less plugins ([details](#using-plugins))

The `filename` option is not necessary, it's handled automatically by this plugin. The `compress` option is not supported -- if you are trying to minify your css, use [gulp-minify-css](https://github.com/jonathanepollack/gulp-minify-css). No `sourceMap` options are supported -- if you are trying to generate sourcemaps, use [gulp-sourcemaps](https://github.com/floridoo/gulp-sourcemaps).

## Minifying CSS

If you want to minify/compress your css, you can use either the [gulp-minify-css](https://github.com/jonathanepollack/gulp-minify-css) plugin for gulp, or the [less-clean-css](https://github.com/less/less-plugin-clean-css) plugin for less. Examples of both are shown below:

```js
// Using a less plugin to minify css
var LessPluginCleanCSS = require('less-plugin-clean-css'),
    cleancss = new LessPluginCleanCSS({ advanced: true });

gulp.src('./less/**/*.less')
  .pipe(less({
    plugins: [cleancss]
  }))
  .pipe(gulp.dest('./public/css'));
```

```js
// Using a gulp plugin to minify css
var minifyCSS = require('gulp-minify-css');

gulp.src('./less/**/*.less')
  .pipe(less())
  .pipe(minifyCSS())
  .pipe(gulp.dest('./public/css'));
```

## Using Plugins

Less now supports plugins, which can add additional functionality like minifying css as shown above. Here's an example of how to use plugins with `gulp-sources-less` using both the [clean-css plugin](https://github.com/less/less-plugin-clean-css) and the [autoprefix plugin](https://github.com/less/less-plugin-autoprefix).

```js
var LessPluginCleanCSS = require('less-plugin-clean-css'),
    LessPluginAutoPrefix = require('less-plugin-autoprefix'),
    cleancss = new LessPluginCleanCSS({ advanced: true }),
    autoprefix= new LessPluginAutoPrefix({ browsers: ["last 2 versions"] });

gulp.src('./less/**/*.less')
  .pipe(less({
    plugins: [autoprefix, cleancss]
  }))
  .pipe(gulp.dest('./public/css'));
```

More info on LESS plugins can be found at http://lesscss.org/usage/#plugins, including a current list of all available plugins.

## Source Maps

`gulp-sources-less` can be used in tandem with [gulp-sourcemaps](https://github.com/floridoo/gulp-sourcemaps) to generate source maps for your files. You will need to initialize [gulp-sourcemaps](https://github.com/floridoo/gulp-sourcemaps) prior to running the gulp-sources-less compiler and write the source maps after, as such:

```js
var sourcemaps = require('gulp-sourcemaps');

gulp.src('./less/**/*.less')
  .pipe(sourcemaps.init())
  .pipe(less())
  .pipe(sourcemaps.write())
  .pipe(gulp.dest('./public/css'));
```

By default, [gulp-sourcemaps](https://github.com/floridoo/gulp-sourcemaps) writes the source maps inline in the compiled CSS files. To write them to a separate file, specify a relative file path in the `sourcemaps.write()` function, as such:

```js
var sourcemaps = require('gulp-sourcemaps');

gulp.src('./less/**/*.less')
  .pipe(sourcemaps.init())
  .pipe(less())
  .pipe(sourcemaps.write('./maps'))
  .pipe(gulp.dest('./public/css'));
```

## Error Handling

By default, a gulp task will fail and all streams will halt when an error happens. To change this behavior check out the error handling documentation [here](https://github.com/gulpjs/gulp/blob/master/docs/recipes/combining-streams-to-handle-errors.md)

---
_Source: https://npm.io/package/gulp-sources-less · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
