-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
[examples/react-rich] Fix: Invalid background-image url path cause missing Toolbar format icons in Vite build bundle. #6063
Conversation
…build fail to bundle Toolbar format icons.
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
I think a better fix is to move the icons folder from public to src, then the relative paths in the css will work and vite will bundle them (mostly inline as data urls) |
I am OK to move to src/assets or even I suggest to consider this fix as it's impact is isolated. |
If you |
Sure, I can do that. |
…es vite build fail to bundle Toolbar format icons." This reverts commit aa98b4c.
Move icons from /public to /src as etrepum suggests.
Added icons to src.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi!
Thanks for this PR! However I would ask you to keep images in public folder and instead simply fix URIs in css file.
Current approach makes Vite (as it's configured now) to inline all images within resulting CSS. Which is unnecessary.
See how examples/reach-rich-collab
works, I fixed it there already.
Either approach should be OK as the fix is straightforward. My suggestion is to follow Lexical team's suggested static assets handling for React apps. My two cents, react-rich<./pre> is actuallyreact-rich-with-vite. As React suggests Next.js, Remix, Getsby, Expo etc for quickstart, Lexical may plan examples for other React frameworks as well. |
Unfortunately I can't merge this until the request for changes review is dismissed, if you'd like to submit this fix as a new PR please do so. |
Description
Current
vite build
used byyarn build
does not bundle Toolbar format icon SVG files. This causes missing Toolbar format icons in production build. This is caused by invalidbackground-image url
path ini.undo
and other Toolbar format icon selectors in 'src/styles.css'. The fix is changing those urls fromi.undo { background-image: url(icons/arrow-counterclockwise.svg); }
to set to root directory
i.undo { background-image: url(/icons/arrow-counterclockwise.svg); }
Please see more on Static Asset Handling The public Directory section.
Test Plan
lexical
repo and run thereact-rich
git clone https://github.com/facebook/lexical.git
cd examples/react-rich
yarn
yarn dev
Before
yarn build
. The command will complain like thisyarn preview
shows missing Toolbar format icons in RichText example.dist
.After
background-iamge url
insrc/styles.css
.yarn dev
.react-rich
run as expected.yarn build
. The command run successfully without complaints.yarn preview
anddist
bundle all have expected Toolbar format icons.