0.1.1 • Published 10 years ago
varlessify v0.1.1
varlessify
require() LESS variables into your JS using Browserify
example usage
If you have a variables.less file:
@foo: #fff;
@bar: 1 + 1;
@baz: @bar + @bar;and a main.js:
var varless = require('varless');
var foo = varless.get('foo');
var bar = varless.get('bar');
var baz = varless.get('baz');
console.log(foo, bar, baz);then after browserifying:
$ browserify main.js -t [ varlessify --file ./variables.less ] > bundle.jsyou get...
var foo = "#ffffff";
var bar = "2";
var baz = "4";
console.log(foo, bar, baz);how to script
varless.get(variable)
varless.get(lessFile, variable)You can specify the less file either as a parameter to varless.get or as a build option. If both are specified, the parameter takes precedence.
how to browserify
On the command line:
$ browserify main.js -t varlessify > bundle.jsOr, with options:
$ browserify main.js -t [ varlessify --file ./variables.less ] > bundle.jsWith the Browserify API:
browserify()
.add('main.js')
.transform('varlessify', { file: './variables.less' })
.bundle();transform options
file
A file to parse for variable declarations by default.
paths
An array of paths to search for during LESS parsing of @import declarations.
installation
Just plain ol' npm installation:
npm install varlessifylicense
MIT



