soda-x / less-json-import-loader

load variable from json sources to Less files
MIT License
2 stars 1 forks source link

NPM version Build Status Build status Coverage Status Dependency Status Greenkeeper badge

less json import loader

load less variables or css variables from json sources to Less files

Install

npm install --save-dev less-json-import-loader

Options

Usage

// webpack.config.js
{
  module: {
    rules: [
      { test: /\.less$/, use: [ "less-loader", "less-json-import-loader" ] }
    ]
  }
}

before:

// a.less
@json-import "./test.json";
background: #222;
// test.json
{
  "a": "#123456"
}

after

@a-md5: 1;
:root {
  --a-md5: 1;
}
background: #222;

md5: it is the value of md5('path/to/test.json')