How to use Webpack so that css can only be used by a single component

for example, I have two components An and B. How do I get component A to use only A.less , and component B to use only B.less . Because they all have the same class name.
it is known that CSS Module is available. I"d like to know if there are any plug-ins.

A.tsx

import "./A.less";
....
render() {
    return <div className="test"/>
}

A.less

.test{
   color: "red";
}

B.tsx

import "./B.less";
render() {
    return <div className="test"/>
}

B.less

.test{
    color: "blue";
}

the root elements of different components have different class names. For example:
A component

<div className="com-a">
    <div className="test"></div>
</div>

.com-a {
    .test {}
}

B component

<div className="com-b">
    <div className="test"></div>
</div>

.com-b {
    .test {}
}

css module can be opened directly in css-loader

if css module is not enabled, you can only put another class on the outermost layer to distinguish the styles of different components

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1ea15f3-1b4c.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1ea15f3-1b4c.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?