ant-design: Failed to parse source map: 'webpack://antd/./components/config-provider/style/index.less' URL is not supported
- I have searched the issues of this repository and believe that this is not a duplicate.
Reproduction link
https://github.com/sauldeleon/antd-webpack5-repro
Steps to reproduce
- clone this repo
- run
npm i
- run
npm start
- check the logs in the console
What is expected?
React start the application with no warning issues. In certain environments, warning issues are not supported and will crash the build for production environments
What is actually happening?
Webpack 5 throws errors due to loading URL for less files
Edit: as @YouWillBe said, this is due to using react-scripts 5.0.0
which uses webpack 5
Failed to parse source map: ‘webpack://antd/./components/config-provider/style/index.less’ URL is not supported Failed to parse source map: ‘webpack://antd/./components/icon/style/index.less’ URL is not supported Failed to parse source map: ‘webpack://antd/./components/locale-provider/style/index.less’ URL is not supported Failed to parse source map: ‘webpack://antd/./components/time-picker/style/index.less’ URL is not supported
Environment | Info |
---|---|
antd | 4.17.3 |
React | 17.0.2 |
System | All systems |
Browser | Chrome 96.0.4664.110 |
About this issue
- Original URL
- State: open
- Created 3 years ago
- Reactions: 36
- Comments: 61 (1 by maintainers)
Commits related to this issue
- chore: fix `index.less` warning ### error detail ```shell Failed to parse source map: 'webpack://antd/./components/locale-provider/style/index.less' URL is not supported ``` ### Ref - https://www.... — committed to Couch-Coders/6th-starbucks-fe by xoxwgys56 2 years ago
- App ran successfully and the api call to get the notes list was also successfull I had to replace import "antd/dist/antd.css" with antd/dist/antd.min.css due to a compile warning I was seeing in the ... — committed to ayebravo/notesapp by ayebravo 2 years ago
Solution :
- import 'antd/dist/antd.css
replace with+ import 'antd/dist/antd.min.css
Thanks for all your love. Please follow me on GitHub
react-script
升级到5.0.0
之后出现此问题,也就是说从14号开始,所有通过npx create-react-app
创建的项目,引入antd.css
之后都会看到这个警告Don’t be nervous, I just clarified the problem, I believe that the members of antd team will give a solution soon
这个解决方案很有效,谢谢大佬!
Write
@import '~antd/dist/antd.css';
inApp.css
, then import it inApp.js
. Instead of importingantd/dist/antd.css
in the entranceindex.js
. That works for me. You can find it in the Antd docs.thank you for your solution
none of them are worked for me, still get the same error;
yep, seeing this as well. updated to react scripts v5.0.0 just now. hopefully this will be easy to fix
@ppegu Thanks a lot, btw Could you please help explain how that works?
works for me, pretty much thanks
Thank you for the solution ! It should be mentioned in docs
import ‘antd/dist/antd.min.css’ it`s work for me
this is not working for me!!!
As a temporal workarround for me, knowing it is something far from a fix, I have managed to hide the warnings messages modifying the webpack configuration using the
ignoreWarnings
parameter.In my specific scenario, I am using
craco
to overload the webpack configuration provided by CRA, so adding this will do the trick:This avoids the warnings in dev mode and avoids the build for production environment to break, as we have a 0-warning policy for this environment.
More info here
Sorry mate, I do not understand chineese! what do you mean?
Edit: using google translator:
Yeah, thats true. So what can we do? is there any chance to get this fixed? any workarround?