如何从 .css 文件中过滤或提取特定的 CSS 规则集并将其放入单独的文件中

问题描述

是否可以使用 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;
}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)