Closed AlexandrHoroshih closed 1 year ago
I see a possible way to support CSS Layers as follows:
html
, body
, etc.), so things like @layer theme, layout, utilities;
are always included in critical css@layer theme { ... }
) are handled the same way @media
is handled nowIf PR with this feature would be welcome, I'd be happy to work on it π
Absolutely correct
.1
all you need is to make layer definition "not extractable", so it will be always extracted like html
, body
, and so on@layer
all you need is to modify toAst
and fromAst
, but I am not sure how ease it will be to add one extra level of nesting. Not quite sure how Postcss handles this, but probably you will get one extra parent here - https://github.com/theKashey/used-styles/blob/master/src/parser/toAst.ts#L12 and and it's that simple - "restore" it here - https://github.com/theKashey/used-styles/blob/master/src/parser/fromAst.ts#L75If PR with this feature would be welcome, I'd be happy to work on it π
Yes please, my capacity is quite limited now. I even answering to issues a couple of days late πΏ
Relates to #26
Hello and thank you for the awesome library! π
Since CSS Cascade Layers support is gettng better in the browsers, i was wondering if there any plans to support this feature?
Right now it seems to be not supported: I wrote some snapshot tests and current version of
used-styles
just adds all@layer
-related stuff into the critiical styles without considering, if any of styles in that layer are actually usedSo it looks like that some special handling, like it is done for
@media
rules, is needed π€There is a polyfill for CSS Layers and it does work much better with
used-styles
, but since this feature is getting wider support in the browsers (90% according to caniuse), i think, it is a good time to introduce a native supportCSS Layers are pretty cool, since by using it
which is basically a native CSS solution to issue #26
What do you think?