react antd配置less的時候報錯:

ValidationError: Invalid options object. Less Loader has been initialized using an options object that does not match the API schema.
options has an unknown property ‘source’. These properties are valid:
object { lessOptions?, prependData?, appendData?, sourceMap? }

解決方案:將less-loader版本回退到5,然後使用5的配置方式

const { override, fixBabelImports, addLessLoader } = require('customize-cra')

const theme = require('./theme')

 module.exports = override(
   fixBabelImports('antd', {
     libraryDirectory: 'es',
     style: true,
   }),
   addLessLoader({
    //  lessOptions: { // ÷如果使用less-loader@5,請移除 lessOptions 這一級直接配置選項。
      javascriptEnabled: true,
      modifyVars: theme,
    //  },
   }),
 );

antd解決連接:https://github.com/ant-design/ant-design/issues/23624

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章