0.1.1 • Published 9 years ago

varlessify v0.1.1

Weekly downloads
2
License
MIT
Repository
github
Last release
9 years ago

varlessify

require() LESS variables into your JS using Browserify

NPM version build status Dependency status devDependency Status

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.js

you 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.js

Or, with options:

$ browserify main.js -t [ varlessify --file ./variables.less ] > bundle.js

With 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 varlessify

license

MIT