question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

3.0.12 gives non-applicable warning about @apply

See original GitHub issue

What 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:closed
  • Created 2 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
thecrypticacecommented, Jan 10, 2022

Long-story short: apply got better at detecting these cases and also applying css when defined with rules like .something, h3 { … }

1reaction
thecrypticacecommented, Jan 10, 2022

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 in src/assets/css/intervf.css into a rule by itself and that should fix the error you are seeing.

So, what’s going on then?

  1. In src/assets/css/intervf.css you have this rule:
.italic, i, cite, em, var, address, dfn, h3, .h3, h5, .h5 {
  /* clipped */
}
  1. In src/assets/css/global.css you have this rule:
h3, .h3, h5, .h5 {
  @apply italic;
}

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):

/* <div class="a">This will **not** be red</div> */
.a, .b::unknown-and-broken-thing { color: red; }

/* <div class="a">This **will** be red</div> */
.a { color: red; }
.b::unknown-and-broken-thing { color: red; }

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

W3C Accessibility Guidelines (WCAG) 3.0
The W3C Accessibility Guidelines (WCAG) 3.0 provide a wide range of recommendations for making web content more accessible to users with ...
Read more >
Gerrit Code Review - End to end tests
This document provides descriptions of Gerrit end-to-end ( e2e ) test ... That cross test-scope reusability applies to both Gerrit core scenarios and ......
Read more >
Cisco Identity Services Engine Installation Guide, Release 3.0
The OVA templates simplify ISE virtual appliance deployment by automatically applying the minimum resources required for each platform. Table 1.
Read more >
Oracle ILOM 3.0 Feature Set Overview
The Oracle ILOM 3.0 feature set provides common Oracle ILOM functionality that applies to all Oracle Sun Blade modular systems, server modules (blades), ......
Read more >
Hiring Manager's Manual - UN Careers - the United Nations
and one or more screenshots of the error/warning message and of the page on ... The illustration below provides a high-level overview of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found