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

Missing CSS viewport units in build #15841

Open
danielluca opened this issue Jan 25, 2025 · 10 comments
Open

Missing CSS viewport units in build #15841

danielluca opened this issue Jan 25, 2025 · 10 comments

Comments

@danielluca
Copy link

What version of Tailwind CSS are you using?

For example: v4.0.0

What build tool (or framework if it abstracts the build tool) are you using?

For example: astro 5.1.9, tailwindcss/vite 4.0.0

What version of Node.js are you using?

For example: v18.19.0

What browser are you using?

For example: Chrome, Safari, Firefox

What operating system are you using?

For example: macOS, iOS

Describe your issue

Utilities with viewport units like h-dvh or h-[90dvh] are missing in the build. Using them in development is no problem.

@wongjn
Copy link
Contributor

wongjn commented Jan 25, 2025

Seems to be working for me in a super simple Astro project I spun up. Could you provide a project that reproduces the unexpected behavior please? It would be super helpful for us to debug.

@danielluca
Copy link
Author

danielluca commented Jan 25, 2025

I am toggling styles via the script tag in a astro component. While using h-screen everything is working in development and in the static build. While using h-dvh it is only working in development but not in the static build.

The css class .h-dvh is completely missing in the build.

const mobileMenuButton = document.querySelector(
  "[data-mobile-menu-button]",
);

const mobileMenuButtonIcon = document.querySelector(
  "[data-mobile-menu-button-icon]",
);

const defaultStyles = "hidden h-full w-full flex-1 shrink-0 flex-col divide-y overflow-y-auto ring-0 lg:flex lg:w-max lg:flex-row lg:items-center lg:divide-y-0 lg:overflow-visible lg:pb-0";

// Toggling styles with h-dvh
const isOpen = "absolute left-0 top-0 mt-16 flex h-dvh border-t bg-white px-4 shadow-lg w-full flex-1 shrink-0 flex-col divide-y overflow-y-auto ring-0 lg:flex lg:w-max lg:flex-row lg:items-center lg:divide-y-0 lg:overflow-visible lg:pb-0";

mobileMenuButton?.addEventListener("click", () => {
  const navigationList = document.querySelector("[data-navigation-list]");

  mobileMenuButtonIcon?.classList.toggle("ph-list");
  mobileMenuButtonIcon?.classList.toggle("ph-x");

  if (navigationList) {
    navigationList.className = navigationList.className === isOpen ? defaultStyles : isOpen;
    return;
  }
});

@wongjn
Copy link
Contributor

wongjn commented Jan 25, 2025

Could you provide a project that has that code that reproduces the unexpected behavior please?

@devcustrom
Copy link

devcustrom commented Jan 26, 2025

Could you provide a project that has that code that reproduces the unexpected behavior please?

https://github.com/devcustrom/tailwindbug

@devcustrom
Copy link

devcustrom commented Jan 26, 2025

Could you provide a project that has that code that reproduces the unexpected behavior please?

https://github.com/devcustrom/tailwindbug

В моём случае проблема была из-за

--spacing-4.5: 18px;
--spacing-5.5: 22px;

@devcustrom
Copy link

devcustrom commented Jan 26, 2025

Could you provide a project that has that code that reproduces the unexpected behavior please?

https://github.com/devcustrom/tailwindbug

В моём случае проблема была из-за

--spacing-4.5: 18px;
--spacing-5.5: 22px;

If you use a backslash, then everything works.

--spacing-4\.5: 18px;
--spacing-5\.5: 22px;

@danielluca
Copy link
Author

Could you provide a project that has that code that reproduces the unexpected behavior please?

Please take a look at https://github.com/danielluca/missing-dvh
As i mentioned, in developing everything is working but not in the build.

Image

Image

@wongjn

@devcustrom
Copy link

Could you provide a project that has that code that reproduces the unexpected behavior please?

Please take a look at https://github.com/danielluca/missing-dvh As i mentioned, in developing everything is working but not in the build.

Image

Image

@wongjn

If you use post css, the class is generated, so you can create a bug fix task in the vite plugin.

@wongjn
Copy link
Contributor

wongjn commented Jan 26, 2025

It seems like none of the unique class names in the PageHeader.astro <script> are picked up in build 🤔

@jamesharding
Copy link

I wonder if this is at all related to #15794 where classes from components are somehow being missed?

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

No branches or pull requests

4 participants