npm install --save-dev less-json-import-loader
prefix
: string
, defualt json-import
lessVariable
: boolean
, defualt true
cssVariable
: boolean
, defualt true
hash
: boolean
, defualt false
// 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')