cssLoaderOptions: {
modules: true,
getLocalIdent: (
context: {
resourcePath: string;
},
_: string,
localName: string,
) => {
// 阻止模块化
if (
context.resourcePath.includes(‘node_modules’) ||
context.resourcePath.includes(‘ant.design.pro.less’) ||
context.resourcePath.includes(‘global.css’)
) {
return localName;
}
const match = context.resourcePath.match(/src(.*)/);
if (match && match[1]) {
const antdProPath = match[1].replace('.less', '');
const arr = slash(antdProPath)
.split('/')
.map((a: string) => a.replace(/([A-Z])/g, '-$1'))
.map((a: string) => a.toLowerCase());
return `ren${arr.join('-')}-${localName}`.replace(/--/g, '-');
}
return localName;
},
},