OneBot: Leantime 改造版源码(BOM/Univer 表格/AI 接管/品牌替换等)
This commit is contained in:
29
generateBlocklist.mjs
Normal file
29
generateBlocklist.mjs
Normal file
@@ -0,0 +1,29 @@
|
||||
import fs from 'fs';
|
||||
import postcss from 'postcss';
|
||||
import selectorParser from 'postcss-selector-parser';
|
||||
|
||||
const pjson = JSON.parse(fs.readFileSync('./package.json', 'utf-8'));
|
||||
const css = fs.readFileSync(`./public/dist/css/app.${pjson.version}.min.css`, 'utf-8');
|
||||
const classNames = new Set();
|
||||
|
||||
const addClassIfMatches = (classNode) => {
|
||||
if (classNode.value.startsWith('tw-')) {
|
||||
classNames.add(classNode.value);
|
||||
}
|
||||
};
|
||||
|
||||
const processSelectors = (rule) => {
|
||||
selectorParser(selectors => {
|
||||
selectors.walkClasses(addClassIfMatches);
|
||||
}).processSync(rule);
|
||||
};
|
||||
|
||||
const extractClassesPlugin = postcss.plugin('extract-classes', () => {
|
||||
return (root) => {
|
||||
root.walkRules(processSelectors);
|
||||
};
|
||||
});
|
||||
|
||||
await postcss([extractClassesPlugin]).process(css, { from: undefined });
|
||||
const blocklist = Array.from(classNames);
|
||||
fs.writeFileSync('./blocklist.json', JSON.stringify(blocklist, null, 2));
|
||||
Reference in New Issue
Block a user