@solidpixels/less-plugin-json

0.4.0 • Public • Published

JSON less.js file manager

Usage

In LESS file, you can import JSON file as variables file. Regular JSON property will be flattened with -- separator. To produce LESS maps or lists, prefix variable with dollar.

{
  "border": {
    "size": "10px",
    "color": "red"
  },
  "$features": ["a", "b"],
  "$colors": {
    "red": "#ff0000",
    "green": "#00ff00"
  }
}
@import './variables.json';

body {
  border: @border--size @border--color;
  features: @features;
  color: @colors[red];
}

Will compile to:

body {
  border: 10px red;
  features: a, b;
  colors red;
}

Use

lessc style.less --plugin=index.js

Inspired by https://github.com/fortes/less-plugin-load-json#readme.

Readme

Keywords

Package Sidebar

Install

npm i @solidpixels/less-plugin-json

Weekly Downloads

1

Version

0.4.0

License

ISC

Unpacked Size

4.64 kB

Total Files

4

Last publish

Collaborators

  • martinhakl
  • vosatom