less(3.11.1) 配合6以上的less-loader會報錯
ValidationError: Invalid options object. Less Loader has been initialized using an options object that does not match the API schema.
解決方案
鏈接:https://github.com/ant-design/ant-design/issues/23624
webpack.config.js配置步驟
配置less環境
在方法 getStyleLoaders,添加代碼:
{loader:require.resolve('less-loader')}

增加代碼
if (preProcessor === "less-loader") {
loaders.push(
{
loader: require.resolve(preProcessor),
options: {
sourceMap: isEnvProduction && shouldUseSourceMap,
modifyVars: {
'@primary-color':'#f40'
},
javascriptEnabled: true,
},
}
);

切記開啟
babel-plugin-import的less開關,否則設置主題不生效
"plugins": [
[
"import",
{
"libraryName": "antd",
"libraryDirectory": "es",
"style": true
}
]
]
