3.0.12 gives non-applicable warning about @apply
See original GitHub issueWhat version of Tailwind CSS are you using?
Tailwind version: 3.0.12
What build tool (or framework if it abstracts the build tool) are you using?
@11ty/eleventy 1.0.0, postcss 8.4.5, postcss-cli 9.1.0
What version of Node.js are you using?
14.16.0
What browser are you using?
N/A
What operating system are you using?
macOS 12.1
Reproduction URL
https://github.com/brycewray/eleventy_site (Note: trying to run that repo right now is problematic due to an apparent bug in Eleventy 1.0.0.)
Describe your issue
When running a build for dev or production, Tailwind generates the following error message:
CssSyntaxError: tailwindcss: /Users/thewrays/eleventy_site/src/assets/css/intervf.css:2:1: You cannot `@apply` the `italic` utility here because it creates a circular dependency.
1 | /* === handling Inter VF obliquing */
> 2 | .italic, i, cite, em, var, address, dfn, h3, .h3, h5, .h5 { /* dealing with Inter VF */
| ^
3 | font-variation-settings: 'slnt' -8;
4 | /* previous is needed by Chromium and Safari; its presence makes Firefox "over-slant" Inter VF, so we override that below with the media query for Firefox */
. . . which didn’t occur before 3.0.12. The CSS to which it apparently objects is there to handle the peculiarities of using the variable version of the Inter font for both regular and oblique/italic text. But here’s the thing: that particular CSS doesn’t use @apply
:
/* === handling Inter VF obliquing */
.italic, i, cite, em, var, address, dfn, h3, .h3, h5, .h5 { /* dealing with Inter VF */
font-variation-settings: 'slnt' -8;
/* previous is needed by Chromium and Safari; its presence makes Firefox "over-slant" Inter VF, so we override that below with the media query for Firefox */
font-style: oblique 8deg;
/* previous is needed by Firefox and Safari; it apparently has no effect on Chromium */
}
@supports (-moz-appearance: none) {
.italic, i, cite, em, var, address, dfn, h3, .h3, h5, .h5 {
/* font-variation-settings: normal; */
font-style: normal;
}
}
/* === end, handling Inter VF obliquing */
While I can get around this by using a different font which doesn’t require this kind of babying 😄 I would guess that this issue’s having cropped up in 3.0.12, and never before, is something worth noting.
Issue Analytics
- State:
- Created 2 years ago
- Comments:5
Long-story short: apply got better at detecting these cases and also applying css when defined with rules like
.something, h3 { … }
Hey, thanks for the report and reproduction!
Unfortunately, this is working as intended. The workaround should be fairly simple: split the
.italic
part of the rule insrc/assets/css/intervf.css
into a rule by itself and that should fix the error you are seeing.So, what’s going on then?
src/assets/css/intervf.css
you have this rule:src/assets/css/global.css
you have this rule:This coupled with the fact that
@apply
takes entire rules into account — not just the single selector — because they’re not always equivalent means we detect a circular dependency.For example, these two selectors while seemingly separate, are not (h/t @RobinMalfait for the example):
Since the browser doesn’t know about
::unknown-and-broken-thing
the entire rule gets thrown out and we need to properly handle that with apply.You can read even more details on how apply works in this comment: https://github.com/tailwindlabs/tailwindcss/issues/6451#issuecomment-997034450
Hopefully that answers your question — if you have more questions please feel free to comment.