Failed to parse source map: ‘webpack:antd.componentsiconstyleindex.less‘ URL is not supported

Failed to parse source map: ‘webpack:antd.componentsiconstyleindex.less‘ URL is not supported,第1张

React18.x引入antd4.x的css后 index.less’ Failed to parse source map: 'webpack:URL is not supported

报错问题(下方有解决方案):

Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map: 'webpack://antd/./components/time-picker/style/index.less' URL is not supported

解决方案:
1.npm run eject (将webpack配置暴露出来)
2.进入config/webpack.config.js文件
3.查找“const cssRegex” (加入less)
将其/\.css$/ 修改为 /\.css|less$/ 如下

4.查找“const getStyleLoaders” (加入less-loader)

//具体位置下方图片
{
        loader:'less-loader',
        options:{
          javascriptEnabled:true
        }
},

5.因为 less-loader和 less需要依赖库,所以需要下载,命令如下
npm install less [email protected] -D
6.antd引入样式的css改为less

import "antd/dist/antd.css";  //将其改为less ,如下
import "antd/dist/antd.less"; 

7.运行npm run start 不报错了

解决了给个赞吧,谢谢!!!

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1296688.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-10
下一篇 2022-06-10

发表评论

登录后才能评论

评论列表(0条)

保存