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

[vite-url-rewrite] messes up image-set used with CSS vars #7874

Closed
7 tasks done
qnp opened this issue Apr 23, 2022 · 0 comments · Fixed by #7921
Closed
7 tasks done

[vite-url-rewrite] messes up image-set used with CSS vars #7874

qnp opened this issue Apr 23, 2022 · 0 comments · Fixed by #7921
Labels
feat: css p3-minor-bug An edge case that only affects very specific usage (priority)

Comments

@qnp
Copy link
Contributor

qnp commented Apr 23, 2022

Describe the bug

While background-image: url(var(--bg-url)) is not valid and understood by browsers, the use of CSS vars in image-set is perfectly valid and working. See this codepen experiment (tested in Firefox, Chrome, Safari and Opera)1.

When using image-set, its content is processed via internal vite plugin vite-url-rewrite.

Input:

background-image: image-set(var(--hero--image-webp) 1x, var(--hero--image-jpg) 1x);

Output:

background-image: image-set(url(var(--hero--image-webp) ) 1x, var(--hero--image-jpg) 1x);

which is messed up and not understood by browsers.

This is, I guess, related to that commit (cc @HcySunYang) which incompletely handles CSS vars.

Reproduction

https://stackblitz.com/edit/vitejs-vite-zotkr1

System Info

System:
    OS: macOS Mojave 10.14.6
    CPU: (8) x64 Intel(R) Core(TM) i7-8569U CPU @ 2.80GHz
    Memory: 158.32 MB / 16.00 GB
    Shell: 5.3 - /bin/zsh
  Binaries:
    Node: 16.14.0 - ~/.nvm/versions/node/v16.14.0/bin/node
    Yarn: 1.17.3 - ~/.yarn/bin/yarn
    npm: 8.3.1 - ~/.nvm/versions/node/v16.14.0/bin/npm
  Browsers:
    Chrome: 100.0.4896.127
    Firefox: 99.0.1
    Firefox Developer Edition: 71.0
    Firefox Nightly: 76.0a1
    Safari: 14.1.2
    Safari Technology Preview: 13.2

Used Package Manager

yarn

Logs

No response

Validations

Footnotes

  1. Note that, according to can I use, it is required to use the -webkit--prefixed version for browsers other than Firefox, and the use of direct string url value (no url()) is valid only in Firefox.

@qnp qnp changed the title vite-url-rewrite messes up image-set used with CSS vars [vite-url-rewrite] messes up image-set used with CSS vars Apr 23, 2022
@sapphi-red sapphi-red added feat: css p3-minor-bug An edge case that only affects very specific usage (priority) and removed pending triage labels Apr 23, 2022
This was referenced Apr 27, 2022
@github-actions github-actions bot locked and limited conversation to collaborators May 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feat: css p3-minor-bug An edge case that only affects very specific usage (priority)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants