.a, #b {
color: red;
}
.mixin-class {
.a();
}
.mixin-id {
#b();
}
//配置
{
test: /less\/.+\.less$/,
use: [
'style-loader',
{
loader: 'css-loader',
options: {
modules: true,
localIdentName: '[local]-[hash:base64:5]'
}
},
'less-loader',
'postcss-loader'
]
},
//错误信息
ERROR in ./~/css-loader?{"modules":true,"localIdentName":"[local]-[hash:base64:5]"}!./~/less-loader/dist!./~/postcss-loader/lib!./public/static/less/vols.packages.less
0|luoo-m | Module build failed: Syntax Error
0|luoo-m | (102:5) Unknown word
0|luoo-m | 100 | }
0|luoo-m | 101 | .mixin-class {
0|luoo-m | > 102 | .a();
0|luoo-m | | ^
0|luoo-m | 103 | }
0|luoo-m | 104 | .mixin-id {
0|luoo-m | @ ./public/static/less/vols.packages.less 4:14-197 16:2-20:4 17:20-203
0|luoo-m | @ ./app/containers/vols/packages.js
0|luoo-m | @ ./app/routes/client/vols/index.js
0|luoo-m | @ ./app/routes/client.js
0|luoo-m | @ ./app/client.js
There are no problems with other functions of less for the time being, but when using this mixed code, something goes wrong. Please solve it!
Your style uses 4 loaders, and postcss is applied first in order. This error is thrown by postcss because it cannot parse this syntax, not less.
Screenshots from https://autoprefixer.github.io/
So it should be enough to swap the positions of less-loader and postcss-loader.
I don’t understand. Is this how .a() is written in less?? It should be .a{}