Skip to content

image-set property not converting correctly #17835

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

Closed
y-anzai-colsis opened this issue May 1, 2025 · 3 comments
Closed

image-set property not converting correctly #17835

y-anzai-colsis opened this issue May 1, 2025 · 3 comments

Comments

@y-anzai-colsis
Copy link

y-anzai-colsis commented May 1, 2025

What version of Tailwind CSS are you using?

v4.0.17

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

Astro v5.5.5
@tailwindcss/vite v4.0.17

What version of Node.js are you using?

v22.12.0

What browser are you using?

Chrome

What operating system are you using?

macOS

ideal transformation

bg-[image-set(url(/images/header-bg.jpg.avif)_type('image/avif'),url(/images/header-bg.jpg)_type('image/jpeg'))]
↓↓↓
.bg-\[image-set\(url\(\/images\/header-bg\.jpg\.avif\)_type\(\'image\/avif\'\)\,url\(\/images\/header-bg\.jpg\)_type\(\'image\/jpeg\'\)\)\] {
  background-image: image-set(url(/images/header-bg.jpg.avif) type('image/avif'),url(/images/header-bg.jpg) type('image/jpeg'));
}

transformation of reality

bg-[image-set(url(/images/header-bg.jpg.avif)_type('image/avif'),url(/images/header-bg.jpg)_type('image/jpeg'))]
↓↓↓
.bg-\[image-set\(url\(\/images\/header-bg\.jpg\.avif\)_type\(\'image\/avif\'\)\,url\(\/images\/header-bg\.jpg\)_type\(\'image\/jpeg\'\)\)\]{
  background-image:-webkit-image-set(url(/images/header-bg.jpg.avif) 1x type("image/avif"),url(1x) type("image/jpeg"));
  background-image:image-set(url(/images/header-bg.jpg.avif) 1x type("image/avif"),url(1x) type("image/jpeg"))
}

url(1x) is wrong

@wongjn
Copy link
Collaborator

wongjn commented May 1, 2025

At least in Tailwind Play, it generates fine:

.bg-\[image-set\(url\(\/images\/header-bg\.jpg\.avif\)_type\(\'image\/avif\'\)\,url\(\/images\/header-bg\.jpg\)_type\(\'image\/jpeg\'\)\)\] {
  background-image: image-set(url(/images/header-bg.jpg.avif) type('image/avif'),url(/images/header-bg.jpg) type('image/jpeg'));
}

In Lightning CSS playground (Tailwind uses it in production), the non-prefixed version has no url() wrappers at all:

.bg-\[image-set\(url\(\/images\/header-bg\.jpg\.avif\)_type\(\'image\/avif\'\)\,url\(\/images\/header-bg\.jpg\)_type\(\'image\/jpeg\'\)\)\] {
  background-image: -webkit-image-set(url("/images/header-bg.jpg.avif") 1x type("image/avif"), url("/images/header-bg.jpg") 1x type("image/jpeg"));
  background-image: image-set("/images/header-bg.jpg.avif" 1x type("image/avif"), "/images/header-bg.jpg" 1x type("image/jpeg"));
}

Perhaps it's some Vite/Astro thing?

@y-anzai-colsis
Copy link
Author

Thank you!

Lightning adds 1x, and url() is converted like text.

I'll try writing it differently and see what happens.

@y-anzai-colsis
Copy link
Author

I converted it correctly when I used a Vite project instead of Astro!

I'm not sure yet, but it seems to be caused by Astro.

I'll close it and check on the Astro side.

Thank you!!!

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

2 participants