add global dependencies to less file for webpack, this loader would resolve absolute global file path to relative path.
$ npm install less-import-loader --save-dev
add less-import-loader before less-loader
{
test: /\.less$/,
loader: "style!css!less!less-import-loader"
},
add less-import-loader option in webpack.config.js
lessImportLoader: {
base: process.cwd() + '/src/less/base' // must be absolute path
}
Before:
src/test/a.less
a {
color: white;
}
After:
@import "../less/base";
a {
color: white
}