.babelrc ``` { "presets": [ "es2015", "stage-0", "react" ], "plugins": [ "transform-runtime", [ "import", { "libraryName": "antd", "style": "css" } ] ] } ``` 然后引入组件 ``` import { Table, Icon, Input, Dropdown, Menu, Button } from 'antd'; ``` 可是样式就是出不来,之前还好好的!
Activity
afc163 commentedon Oct 16, 2016
umijs/babel-plugin-import#58
umijs/babel-plugin-import#61
看看是不是这些问题,或者给出更多信息。
cike8899 commentedon Oct 16, 2016
{ test: /.css$/, exclude: path.resolve(__dirname, './node_modules'), loader: 'style-loader!css-loader?modules&camelCase&importLoaders=1&localIdentName=[local]' + '_hash:base64:6!postcss-loader' }, { test: /.css$/, include: path.resolve(__dirname, './node_modules'), loader: 'style-loader!css-loader!postcss-loader' },
webpack的css配置如上,less配置和css配置一样的,发现antd的classname被加上了后缀
afc163 commentedon Oct 16, 2016
看这个回复:umijs/babel-plugin-import#58 (comment)
cike8899 commentedon Oct 16, 2016
cssLoaderWithoutModule lessLoader 这两个变量怎么配置?
afc163 commentedon Oct 16, 2016
简单的说,你配置了 css-modules 的相关功能,它把 antd 的样式也 hash 化了,导致样式不匹配。
建议你把 node_modules 下的文件都 exclude 掉,不要让它走 css-modules。
http://stackoverflow.com/questions/35398733/css-modules-how-do-i-disable-local-scope-for-a-file
css-modules/css-modules#65
cike8899 commentedon Oct 16, 2016
明明将node_modules exclude掉了:
inkinworld commentedon Feb 11, 2017
让antd的less不通过css-module-loader就行了
只让自己的less文件通过css-module-loader
JX-Zhuang commentedon Mar 21, 2018
It can run. :)
JX-Zhuang commentedon Mar 21, 2018
You can see
#3442 (comment)
varrant commentedon Nov 16, 2018
最新webpack4配置,关键是include和exclude,亲测可行,希望能帮到大家。
ghost commentedon Dec 13, 2018
use typescript
huayezhiwu commentedon May 16, 2019
谢谢提供,亲测可行~~
noobalex commentedon Dec 15, 2019
fixed my issue
jianan46 commentedon May 16, 2024
webpack5.91.0配置