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

Most upvoted comments

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

解决方案 :

- import 'antd/dist/antd.css 用。。。来代替 + import 'antd/dist/antd.min.css

这个解决方案很有效,谢谢大佬!

Write @import '~antd/dist/antd.css'; in App.css, then import it in App.js. Instead of importing antd/dist/antd.css in the entrance index.js. That works for me. You can find it in the Antd docs. image

Solution :

- import 'antd/dist/antd.css replace with + import 'antd/dist/antd.min.css

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?

Solution :

- import 'antd/dist/antd.css replace with + import 'antd/dist/antd.min.css

works for me, pretty much thanks

Solution :

- import 'antd/dist/antd.css replace with + import 'antd/dist/antd.min.css

Thank you for the solution ! It should be mentioned in docs

import ‘antd/dist/antd.min.css’ it`s work for me

Solution :

- import 'antd/dist/antd.css replace with + import 'antd/dist/antd.min.css

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:

//craco.config.js

module.exports = {
  plugins: [ ... ],
  webpack: {
    configure: webpackConfig => {
      // other stuff with webpackConfig
      return {
        ...webpackConfig,
        ignoreWarnings: [/Failed to parse source map/],
      }
    },
  },
}

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:

This problem occurred after react-script was upgraded to 5.0.0, which means that starting from the 14th, all projects created through npx create-react-app will see this warning after the introduction of antd.css

Yeah, thats true. So what can we do? is there any chance to get this fixed? any workarround?