node package manager
Loosely couple your services. Use Orgs to version and reuse your code. Create a free org »

less-vars-loader

less-vars-loader

Build status npm npm David node Commitizen friendly semantic-release Code Climate

webpack loader to load variables from less files

Install

npm install --save-dev less-vars-loader

Usage

// some.less 
@my-var: 2px;
const vars = require("less-vars-loader!./some.less");
// vars == { 'my-var': '2px' } 

Camel casing (?camelCase)

The exported keys can be camelCased. This is disabled by default.

const vars = require("less-vars-loader?camelCase!./some.less");
// vars == { myVar: '2px' } 

Resolving variables (?resolveVariables)

For simple @x = @y assignments this module can follow the assigned variable replace it with the last assignment. This is disabled by default.

Attention: Circular assignments are not supported, neither are non-trivial assignment such as calculations.

// some.less 
@a: 1px;
@b: @a;
@c: @b;
const vars = require("less-vars-loader?resolveVariables!./some.less");
// vars == { a: '1px', b: '1px', c: '1px' } 

TODO

  • source map support