broccoli-less-single
![Build Status](https://img.shields.io/travis/gabrielgrant/broccoli-less-single.svg?branch=master&style=flat-square)
The broccoli-less-single plugin compiles .less
files with
less.js.
This plugin is designed to compile a single, primary input file
into a single output file, with a node of @import
d dependencies. This
differs from broccoli-less,
which compiles each .less
file individually into a .css
file and doesn't
support @import
s or a single output file depending on multiple inputs.
This code is based heavily on
broccoli-sass
Installation
npm install --save-dev broccoli-less-single
Usage
var compileLess = require('broccoli-less-single');
var outputNode = compileLess(inputNodes, inputFile, outputFile, options)
-
inputNodes
: An array of nodes that act as the include paths for
less. If you have a single node, pass [node]
.
-
inputFile
: Relative path of the main .less
file to compile. This
file must exist in one of the inputNodes
.
-
outputFile
: Relative path of the output CSS file.
-
options
: A hash of options for less.
Example
var appCss = compileLess(sourceNodes, 'myapp/app.less', 'assets/app.css')
@import
-Example
h1 {
font-size: 200em;
}
@import "sub.less";
html, body {
margin: 20px;
}
Bootstrap-Example
A sample project using bootstrap and broccoli-less-single can be found here.
var Funnel = require('broccoli-funnel');
var compileLess = require('broccoli-less-single');
var mergeTrees = require('broccoli-merge-trees');
var app = new Funnel('app');
var less = compileLess(app, 'styles/app.less', 'assets/app.css', {
paths: ['.', 'bower_components/bootstrap/less']
});
module.exports = mergeTrees([app, less]);