Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add @reference "…" #15565

Merged
merged 1 commit into from
Jan 7, 2025
Merged

Add @reference "…" #15565

merged 1 commit into from
Jan 7, 2025

Conversation

philipp-spiess
Copy link
Member

@philipp-spiess philipp-spiess commented Jan 7, 2025

This PR adds a new @reference "…" API as an replacement for the previously added @import "…" reference. The motivation for a distinct at rule is that @import is already handled outside of Tailwind in some scenarios (e.g. when using in combination with postcss-import, other pre-processors, or frameworks like Svelte). While our implementation of hijacking the media attribute works in this cases, it can cause annoying linter issues because tooling build around @import does not know about our behavior.

To fix this, we've decided to move this mode into a separate at rule that is passed-through in the other tooling. Here's an example of how this would look like in Svelte:

<h1>Hello world!</h1>

<style>
  @reference './theme.css';
  h1 {
    color: var(--theme-color);
  }
</style>

With this change, the Svelte linter would not be detecting unused CSS from the theme.css file as it would if we'd rely on @import.

@philipp-spiess philipp-spiess requested a review from a team as a code owner January 7, 2025 12:27
CHANGELOG.md Outdated Show resolved Hide resolved
await expect(
run(
css`
@reference './foo/bar.css';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to add support for this to IntelliSense. I've made a note to do that.

@philipp-spiess philipp-spiess enabled auto-merge (squash) January 7, 2025 15:40
@philipp-spiess philipp-spiess merged commit d6c4e72 into next Jan 7, 2025
5 checks passed
@philipp-spiess philipp-spiess deleted the feat/atReference branch January 7, 2025 15:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants