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
        }
      ]
    ]