there are two React projects An and B, Project B is a public project, and Project A depends on Project B.
they all rely on the antd component library, but with different versions.
now the way to use B in An is to build, first and then introduce:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>app</title>
<link rel="stylesheet" href="path/to/project/B.css" />
<link rel="stylesheet" href="path/to/project/A.css" />
</head>
<body>
<div id="root_a"></div>
<div id="root_b"></div>
<script src="path/to/project/bundleB.js"></script>
<script src="path/to/project/bundleA.js"></script>
</body>
</html>
the problem is that both A.css and B.css contain antd.css, that can cause pollution. But because the version is different, we can"t just quote one.
trying to wrap a layer of Id, around project B antd.css is similar to -sharproot_b .antd _ xxx {}
, but it doesn"t seem to work:
// b_index.less
-sharproot_b{
@import "~antd/dist/antd.css";
//
}
find a solution ~