Closed c0ncentus closed 1 year ago
a "main" function with html string (or whatever), css string (or whatever) as input and then have as output, a css used ?
That is getCriticalRules
, see https://github.com/theKashey/used-styles/blob/master/__tests__/extraction.spec.tsx#LL27C18-L27C18
Examples uses loadStyleDefinitions
which is a little in between of fully automated style discoverability and "just styles", you better use parseProjectStyles
see https://github.com/theKashey/used-styles/blob/632b8d2b0547e3a084f05b639a870ca1e3926cc5/__tests__/react.integration.spec.tsx#L134
That would be something like
const styles = parseProjectStyles({
style: `body { padding:0 }`
});
const critical = getCriticalRules('<HTML><body>hello</body></HTML>', styles);
This code works, but TypeScript will complain
ok thanks :)
I read that you scan html and css but maybe isnt so easy ... and also put 'hybrid', server side rendering and whatever ...
Can you tell me if you can expose a "main" function with html string (or whatever), css string (or whatever) as input and then have as output, a css used ?