Skip to content

[Bug]: Responsive space-x-* utilities are not obfuscated correctly #189

Description

@c0b41

Prerequisites

  • I have searched the existing issues and discussions.
  • I am using the latest version of tailwindcss-obfuscator.

Package version

latest

Tailwind CSS version

v3

Bundler / framework

Vite

What happened?

Hi! I found an issue when using tailwindcss-obfuscator with Tailwind CSS 3.4.13.

Responsive utilities such as md:flex-row are obfuscated correctly, but responsive space-x-* utilities such as md:space-x-2 are not.

Tailwind correctly generates the base space-x-2 rule:

.space-x-2 > :not([hidden]) ~ :not([hidden]) {
    --tw-space-x-reverse: 0;
    margin-left: calc(.5rem * (1 - var(--tw-space-x-reverse)));
    margin-right: calc(.5rem * var(--tw-space-x-reverse));
}

The obfuscator correctly obfuscates other utilities from the same element. For example:

.s-w8c {
    flex-direction: column;
}

.s-oe1 {
    flex-direction: row;
}

.s-t5f {
    display: flex;
}

Expected behavior
md:space-x-2 should be obfuscated just like other responsive utilities.

@media (min-width: 768px) {
    .s-xyz > :not([hidden]) ~ :not([hidden]) {
        --tw-space-x-reverse: 0;
        margin-left: calc(.5rem * (1 - var(--tw-space-x-reverse)));
        margin-right: calc(.5rem * var(--tw-space-x-reverse));
    }
}

Environment
Tailwind CSS: 3.4.13
tailwindcss-obfuscator: latest
React
Vite

Expected behavior

md:space-x-2 should be obfuscated just like other responsive utilities.

For example, conceptually:

@media (min-width: 768px) {
    .s-xyz > :not([hidden]) ~ :not([hidden]) {
        --tw-space-x-reverse: 0;
        margin-left: calc(.5rem * (1 - var(--tw-space-x-reverse)));
        margin-right: calc(.5rem * var(--tw-space-x-reverse));
    }
}

Minimal reproduction

<div className="flex flex-col gap-4 mb-4 align-middle md:space-x-2 md:flex-row">
  <Card className="py-4 md:w-1/2">
    ...
  </Card>

  <Card className="py-4 md:w-1/2">
    ...
  </Card>
</div>

Logs / stack traces

Environment

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions