Install
npm install --save-dev less-json-import-loader
Options
-
prefix
:string
, defualtjson-import
-
lessVariable
:boolean
, defualttrue
-
cssVariable
:boolean
, defualttrue
-
hash
:boolean
, defualtfalse
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')