Skip to content

Chore: Inline toolbar SVG icons in examples via Vite asset handling#8430

Merged
etrepum merged 1 commit into
facebook:mainfrom
markselby9:fix-7236-inline-svg-icons-in-examples
Apr 30, 2026
Merged

Chore: Inline toolbar SVG icons in examples via Vite asset handling#8430
etrepum merged 1 commit into
facebook:mainfrom
markselby9:fix-7236-inline-svg-icons-in-examples

Conversation

@markselby9

Copy link
Copy Markdown
Contributor

Description

Closes #7236.

The five examples react-rich, react-rich-collab, react-table, extension-react-table, and node-replacement reference their toolbar SVG icons from public/icons/ via paths Vite cannot resolve at build time, so the icons are emitted as separate HTTP requests at runtime instead of inlined as data:image/svg+xml URIs.

This PR moves each example's public/icons/ to src/icons/ (via git mv so history is preserved) and updates src/styles.css to reference them as url(./icons/foo.svg). Vite then inlines each icon as a data URI in the built CSS — every icon is well under the default 4096-byte assetsInlineLimit. Verified per example: the built CSS contains 10 inlined data URIs, zero remaining external icon references, and no dist/icons/ directory is created.

This adopts the pattern already used by examples/node-state-style/, which uses src/icons/ and unquoted url(./icons/foo.svg) — the existing in-repo precedent.

Notes

  • react-rich-collab previously used absolute url(/icons/...) paths while the other four used bare url(icons/...). Both forms are unified to url(./icons/...).
  • Pre-existing url(../images/icons/plus.svg) references in react-table and extension-react-table (lines 509-535 / 518-544) target a non-existent path on main and are left untouched — Vite already warns about them on main. A fix for those is out of scope for this PR.
  • The five examples ship byte-identical icon sets. They are intentionally duplicated rather than dedup'd because pnpm-workspace.yaml excludes examples/**/* and each example's README markets it as standalone via "Open in StackBlitz" — sharing assets through a workspace package would break that copy-paste flow.

Test plan

Before

npm run build in any of the five affected examples produces a dist/icons/ directory and CSS with url("./icons/foo.svg") left as runtime asset requests (or, for react-rich-collab, url(/icons/foo.svg)).

After

For each of the five examples:

  • npm install && npm run build succeeds.
  • dist/assets/index-*.css contains 10 occurrences of data:image/svg+xml,... and zero url(/icons/...) / url(./icons/...) / url(icons/...) references.
  • No dist/icons/ directory is created (icons are not copied as separate assets).
  • Visual verification in Chrome on react-rich (single editor) and react-rich-collab (split-screen Yjs collab) — all 10 toolbar icons render correctly.
Closes facebook#7236.

Five examples (`react-rich`, `react-rich-collab`, `react-table`,
`extension-react-table`, `node-replacement`) referenced their toolbar
SVG icons from `public/icons/` via paths Vite cannot resolve at build
time, so the icons were emitted as separate HTTP requests at runtime.

Move each example's `public/icons/` to `src/icons/` and update the
`src/styles.css` references to `url(./icons/foo.svg)`. Vite then inlines
each icon as a `data:image/svg+xml` URI in the built CSS (each icon is
under the default 4096-byte `assetsInlineLimit`). Verified per example:
the built CSS contains 10 data URIs and zero external icon references,
and no `dist/icons/` directory is created.

This adopts the pattern already used by `examples/node-state-style/`,
which uses `src/icons/` and `url(./icons/foo.svg)` (unquoted) — the
existing in-repo precedent. `react-rich-collab` previously used absolute
`url(/icons/...)` paths while the other four used bare `url(icons/...)`;
both forms are unified to `url(./icons/...)`.

Pre-existing `url(../images/icons/plus.svg)` references in
`react-table` and `extension-react-table` (lines 509-535 / 518-544)
target a non-existent path on `main` and are left untouched — Vite
already warns about them and a fix is out of scope for this change.
@vercel

vercel Bot commented Apr 30, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
lexical Ready Ready Preview, Comment Apr 30, 2026 8:13am
lexical-playground Ready Ready Preview, Comment Apr 30, 2026 8:13am

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Apr 30, 2026
@etrepum etrepum added the extended-tests Run extended e2e tests on a PR label Apr 30, 2026

@etrepum etrepum left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good assuming all build checks still pass

@etrepum etrepum added this pull request to the merge queue Apr 30, 2026
Merged via the queue into facebook:main with commit 887f79c Apr 30, 2026
55 of 60 checks passed
@etrepum etrepum mentioned this pull request May 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. extended-tests Run extended e2e tests on a PR

2 participants