Skip to content

A webpack loader than extracts variables from less files and makes them available via JS

License

Notifications You must be signed in to change notification settings

pactsafe/less-vars-loader

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

54 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 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' }

TODO

  • source map support

About

A webpack loader than extracts variables from less files and makes them available via JS

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 93.3%
  • CSS 6.7%