react18中引入antv-x6和antd后报警告:Compiled with warnings.
控制台报如下错误:
WARNING in ./node_modules/@antv/x6-react-shape/es/view.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from 'C:\Users\yunlu\Desktop\yuntuan\yuntuan-react\node_modules\@antv\x6-react-shape\src\view.ts' file: Error: ENOENT: no such file or directory, open 'C:\Users\yunlu\Desktop\yuntuan\yuntuan-react\node_modules\@antv\x6-react-shape\src\view.ts'
WARNING in ./node_modules/antd/dist/antd.css (./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[1].oneOf[5].use[1]!./node_modules/postcss-loader/dist/cjs.js??ruleSet[1].rules[1].oneOf[5].use[2]!./node_modules/source-map-loader/dist/cjs.js!./node_modules/antd/dist/antd.css)
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
看起来是source map和node_modules的错误,所以我们改一下webpack.config.js
中的source map配置
找到source map
配置后,在exclude
中把node_modules
文件夹添加进去,表示忽略这个文件夹下的文件内容
exclude: [/@babel(?:/|\{1,2})runtime/,/node_modules/],
然后再npm start,发现警告已经没有了!