#### antd的less配置不开启css module,但是代码里面想用css module加载样式,方便局部改组件原样式
"antd": "^4.18.3",
"webpack": "^5.65.0",
"less": "^4.1.2",
"less-loader": "^10.2.0",
"postcss-loader": "^6.2.1",
### webpack的module的rules配置
```
{
test: /\.css$/,
use: [
'style-loader',
'css-loader',
],
},
{
test: /\.less$/,
use: [
'style-loader',
{ loader: 'css-loader', options: { modules: true, importLoaders: 1 } },
{
loader: 'postcss-loader',
},
{
loader: 'less-loader', options: {
lessOptions: {
importLoaders: 1, javascriptEnabled: true,
}
}
},
],
exclude: /node_modules/,
},
```
### App组件引入全局样式,index.less 里@import '~antd/dist/antd.less';,还可以修改antd提供的样式变量
```
import './index.less';
import 'antd/dist/antd.css';//这个要引入,不然antd的样式加载不了
```
然后就可以用import styles from 'path',组件里用className = {styles.name}去加载样式了