修改设置vue design/iview的全局主题的时候,less-loader横插一脚bug,版本太高兼容性报错?

问题

按照iview文档设置vue design/iview的全局主题的时候,出现了下面的报错,导致项目无法启动

Failed to compile
./src/Home/less/antMotionStyle.less (./node_modules/css-loader/dist/cjs.js??ref--6-oneOf-7-1!./node_modules/postcss-loader/src??postcss!./node_modules/less-loader/dist/cjs.js??ref--6-oneOf-7-3!./src/Home/less/antMotionStyle.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? }
This error occurred during the build time and cannot be dismissed.

解决

方案一:

将package.json里的less-loader版本换成^5.0.0,然后删除node_module再重新npm install即可

原因:

后来发现我的less-lodaer版本6.1.3,而公司之前的项目里的less-loader是5.0.0版本,当我把版本降级之后,意外地成功了,后来查阅相关资料后,发现其实6+版本的兼容性还有问题。

方案二:

修改vue.config.js配置

https://juejin.im/post/5ec040b4e51d454da515dee9

{
  loader: "less-loader",
  options: {
    lessOptions: {
      javascriptEnabled: true
    }
  }
}

你可能感兴趣的:(bug,html,vue,less,less-loader)