Page MenuHomePhabricator

CSS-only icon: Icons within buttons not working in the Vite dev sandbox
Closed, ResolvedPublic

Description

We recently made a change to the syntax of the code that sets the mask-image rule for CSS-only icons within buttons, removing some unnecessary variable interpolation that didn't work with the PHP less compiler used in MediaWiki. However, this change broke the Less in the Vite sandbox (but not the Vitepress site):

image.png (1×2 px, 553 KB)

As you can see in the screenshot, the @background-image-url variable is not getting parsed.

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

I spent some time digging into this – I was wondering why things were working in Vitepress (in codex-docs) but not in Vite itself (in codex core). Was there some Less or PostCSS config getting applied in Vitepress that we needed to use in Vite proper for correct variable interpolation here?

It turns out that the Codex Docs are already getting built with Vite 4 (which was released in December of last year; meanwhile Codex itself is still getting built with Vite 3.

I'm going to see if bumping Codex up to Vite 4 fixes the problem here (and doesn't break other things). We may want to consider upgrading everything to use Vite 4. However, from the Vite migration guide, I did see the following note (under Modern Browsers baseline change):

The modern browser build now targets safari14 by default for wider ES2020 compatibility (bumped from safari13). This means that modern builds can now use BigInt and that the nullish coalescing operator isn't transpiled anymore. If you need to support older browsers, you can add @vitejs/plugin-legacy as usual.

So if we upgrade Vite to v4, Codex may stop supporting Safari v13 and below; theoretically we are still supposed to support back to v10? Would be great to be able to dedicate some QA resources to testing Codex before and after a Vite upgrade in older Safari versions...

Confirming that the Less variable interpolation issue is fixed when we upgrade Codex to Vite 4.

Screenshot 2023-04-06 at 2.00.21 PM.png (1×1 px, 283 KB)

Change 906663 had a related patch set uploaded (by Eric Gardner; author: Eric Gardner):

[design/codex@main] build: Update Vite, Vitepress, and related libraries

https://gerrit.wikimedia.org/r/906663

Change 906663 merged by jenkins-bot:

[design/codex@main] build: Update Vite, Vitepress, and related libraries

https://gerrit.wikimedia.org/r/906663

AnneT claimed this task.
AnneT reassigned this task from AnneT to egardner.

Change 911932 had a related patch set uploaded (by VolkerE; author: VolkerE):

[mediawiki/core@master] Update Codex from v0.9.0 to v0.9.1

https://gerrit.wikimedia.org/r/911932

Test wiki created on Patch demo by ATomasevich (WMF) using patch(es) linked to this task:
https://patchdemo.wmflabs.org/wikis/9a9f20a61d/w

Change 911932 merged by jenkins-bot:

[mediawiki/core@master] Update Codex from v0.9.0 to v0.9.1

https://gerrit.wikimedia.org/r/911932

Test wiki on Patch demo by ATomasevich (WMF) using patch(es) linked to this task was deleted:

https://patchdemo.wmflabs.org/wikis/9a9f20a61d/w/

Test wiki on Patch demo by EGardner (WMF) using patch(es) linked to this task was deleted:

https://patchdemo.wmflabs.org/wikis/97ecb286bb/w/