https://github.com/joscha/less-vars-loader
A webpack loader than extracts variables from less files and makes them available via JS
https://github.com/joscha/less-vars-loader
Last synced: 9 months ago
JSON representation
A webpack loader than extracts variables from less files and makes them available via JS
- Host: GitHub
- URL: https://github.com/joscha/less-vars-loader
- Owner: joscha
- License: mit
- Created: 2016-09-26T13:16:43.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-02-18T13:07:18.000Z (almost 9 years ago)
- Last Synced: 2025-04-01T10:37:35.024Z (10 months ago)
- Language: JavaScript
- Size: 23.4 KB
- Stars: 14
- Watchers: 1
- Forks: 5
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# less-vars-loader
[](https://travis-ci.org/joscha/less-vars-loader)
[](https://www.npmjs.com/package/less-vars-loader)



[](http://commitizen.github.io/cz-cli/)
[](https://github.com/semantic-release/semantic-release)
[](https://codeclimate.com/github/joscha/less-vars-loader)
[webpack](https://webpack.github.io) loader to load variables from [less](http://lesscss.org/) files
## Install
```
npm install --save-dev less-vars-loader
```
## Usage
```less
// some.less
@my-var: 2px;
```
```js
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.
```js
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.
```less
// some.less
@a: 1px;
@b: @a;
@c: @b;
```
```js
const vars = require("less-vars-loader?resolveVariables!./some.less");
// vars == { a: '1px', b: '1px', c: '1px' }
```
## TODO
* source map support