/less-json-import-loader

load variable from json sources to Less files

Primary LanguageJavaScriptMIT LicenseMIT

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

  • prefix: string, defualt json-import

  • lessVariable: boolean, defualt true

  • cssVariable: boolean, defualt true

  • hash: boolean, defualt false

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