是否可以使用 webpack(可能使用插件)或 nodejs 从 .css 文件中提取或过滤某些特定的 CSS 规则集,并将其放入单独的文件(fs 节点)中?如果是,如何?
例如
我想从 .my_class1
中提取 all.css
规则集并将其放入单独的文件 extracted.css
提取前
/* all.css */
.my_class1 {
color: red;
background: red;
}
.my_class2 {
color: green;
background: green;
}
.my_class3 {
color: blue;
background: blue;
}
提取后
/* all.css */
.my_class2 {
color: green;
background: green;
}
.my_class3 {
color: blue;
background: blue;
}
/* extracted.css */
.my_class1 {
color: red;
background: red;
}