Implemented Tailwind CSS class list extraction and integrated it into the build process of the frontend package
Some checks failed
Dev Publish: Nuget / Publish Dev Packages (push) Failing after 16s
Some checks failed
Dev Publish: Nuget / Publish Dev Packages (push) Failing after 16s
This commit was merged in pull request #2.
This commit is contained in:
25
Hosts/Moonlight.Frontend.Host/Styles/extract-classes.mjs
Normal file
25
Hosts/Moonlight.Frontend.Host/Styles/extract-classes.mjs
Normal file
@@ -0,0 +1,25 @@
|
||||
import fs from 'fs';
|
||||
import selectorParser from 'postcss-selector-parser';
|
||||
|
||||
export default function extractTailwindClasses(opts = {}) {
|
||||
const classSet = new Set();
|
||||
|
||||
return {
|
||||
postcssPlugin: 'extract-tailwind-classes',
|
||||
Rule(rule) {
|
||||
selectorParser(selectors => {
|
||||
selectors.walkClasses(node => {
|
||||
classSet.add(node.value);
|
||||
});
|
||||
}).processSync(rule.selector);
|
||||
},
|
||||
OnceExit() {
|
||||
const classArray = Array.from(classSet).sort();
|
||||
fs.mkdirSync('../../../Moonlight.Frontend/Styles', { recursive: true });
|
||||
fs.writeFileSync('../../../Moonlight.Frontend/Styles/Moonlight.Frontend.map', classArray.join('\n'));
|
||||
console.log(`Extracted classes ${classArray.length}`);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
extractTailwindClasses.postcss = true;
|
||||
Reference in New Issue
Block a user