Skip to content

Vite: Work around crash when .svg file contains # or ?#16957

Merged
philipp-spiess merged 1 commit into
mainfrom
fix/vite-hash-svg
Mar 5, 2025
Merged

Vite: Work around crash when .svg file contains # or ?#16957
philipp-spiess merged 1 commit into
mainfrom
fix/vite-hash-svg

Conversation

@philipp-spiess

@philipp-spiess philipp-spiess commented Mar 5, 2025

Copy link
Copy Markdown
Contributor

Closes #16877

This PR works around #16877 by not registering .svg files containing a # or ? as a watch dependency for now.

Test plan

  • Add a file to the Vite playground called src/c#.svg
  • Observe Vite no longer prints errors

@philipp-spiess philipp-spiess marked this pull request as ready for review March 5, 2025 12:01
@philipp-spiess philipp-spiess requested a review from a team as a code owner March 5, 2025 12:01

@RobinMalfait RobinMalfait left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

That's unfortunate that Vite crashes here; Does that mean that if you have these SVGs in your project that changes are never reflected and you have to restart your build for them to take effect?

Because I think the only reason Vite is crashing due to our plugin is just because we mark it with addWatchFile?

@philipp-spiess

Copy link
Copy Markdown
Contributor Author

Does that mean that if you have these SVGs in your project that changes are never reflected and you have to restart your build for them to take effect?

Correct if you have .svg with # in the name right now, Vite will print a warning and not pick up any changes. This change makes it so that Vite wont print a warning and won't error in some other setups but also does not pick up any changes. We can revert this once the upstream issue is fixed: vitejs/vite#19563

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

Successfully merging this pull request may close these issues.

[v4.0.8] Storybook + Vite crashes if filename contains #

2 participants