webpack loader to load variables from less files
npm install --save-dev less-vars-loader
// some.less
@my-var: 2px;
const vars = require("less-vars-loader!./some.less");
// vars == { 'my-var': '2px' }
The exported keys can be camelCased. This is disabled by default.
const vars = require("less-vars-loader?camelCase!./some.less");
// vars == { myVar: '2px' }
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 assignments 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' }
- source map support