Repository navigation
Closed
Copy link
Labels
contribution welcomefeat: cssp3-downstream-blockerBlocking the downstream ecosystem to work properly (priority)
Description
Describe the bug
The Vite development server's HMR process crashes when an asset file (e.g., an SVG imported using ?url) is deleted, if Tailwind CSS v4 is integrated using @import "tailwindcss"; and the @tailwindcss/vite plugin.
Here's the stack trace:
6:14:36 PM [vite] Internal server error: ENOENT: no such file or directory, open '/home/geomaster/Projects/test/vite-tailwind4-asset-delete-repro/src/assets/icon.svg'
Plugin: vite:css-analysis
File: /home/geomaster/Projects/test/vite-tailwind4-asset-delete-repro/src/index.css
at async open (node:internal/fs/promises:638:25)
at async Object.readFile (node:internal/fs/promises:1242:14)
at async fileToDevUrl (file:///home/geomaster/Projects/test/vite-tailwind4-asset-delete-repro/node_modules/.pnpm/vite@6.2.5_jiti@2.4.2_lightningcss@1.29.2/node_modules/vite/dist/node/chunks/dep-Pj_jxEzN.js:13597:21)
at async TransformPluginContext.transform (file:///home/geomaster/Projects/test/vite-tailwind4-asset-delete-repro/node_modules/.pnpm/vite@6.2.5_jiti@2.4.2_lightningcss@1.29.2/node_modules/vite/dist/node/chunks/dep-Pj_jxEzN.js:48876:27)
at async EnvironmentPluginContainer.transform (file:///home/geomaster/Projects/test/vite-tailwind4-asset-delete-repro/node_modules/.pnpm/vite@6.2.5_jiti@2.4.2_lightningcss@1.29.2/node_modules/vite/dist/node/chunks/dep-Pj_jxEzN.js:47680:18)
at async loadAndTransform (file:///home/geomaster/Projects/test/vite-tailwind4-asset-delete-repro/node_modules/.pnpm/vite@6.2.5_jiti@2.4.2_lightningcss@1.29.2/node_modules/vite/dist/node/chunks/dep-Pj_jxEzN.js:41327:27)
at async viteTransformMiddleware (file:///home/geomaster/Projects/test/vite-tailwind4-asset-delete-repro/node_modules/.pnpm/vite@6.2.5_jiti@2.4.2_lightningcss@1.29.2/node_modules/vite/dist/node/chunks/dep-Pj_jxEzN.js:42807:24) (x4)
I'm not sure if the issue is Vite-related or Tailwind-related, so I'm filing an issue with both.
Reproduction
https://github.com/geomaster/vite-tailwind-v4-svg-delete-repro
Steps to reproduce
pnpm installpnpm dev
In another terminal, while the dev server is running, execute the following command to simulate removing the asset reference and deleting the file:
sed -i '/import iconUrl from/d' src/App.tsx && sed -i '/<img src={iconUrl}/d' src/App.tsx && rm src/assets/icon.svg && echo "Triggered bug sequence."
Observe the terminal running pnpm dev. It will crash.
System Info
Node: 22.13.1
Yarn: 1.22.22
pnpm: 10.6.5
OS: Linux 6.13.7-arch1-1 #1 SMP PREEMPT_DYNAMIC Thu, 13 Mar 2025 18:12:00 +0000 x86_64 GNU/LinuxUsed Package Manager
pnpm
Logs
No response
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to vuejs/core instead.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.
Metadata
Metadata
Assignees
Labels
contribution welcomefeat: cssp3-downstream-blockerBlocking the downstream ecosystem to work properly (priority)
Activity
MoperMop commentedon Apr 11, 2025
Some things I noticed while testing:
First: it doesn't matter how long it takes you to delete the asset after deleting the reference to it. It doesn't even matter if you restart the server in between. It only matters that you referenced the asset at one point, and the asset no longer exists. Though, restarting the server while the asset is deleted will fix it.
Secondly: restoring the asset will get the server to function again without having to restart it. Though deleting the asset will break the server again. And, if you restore the asset while the server is off the server will still break if you delete it again.
BenzidaneMo commentedon Apr 28, 2025
A puzzling observation: after the initial deletion, adding server: { hmr: { overlay: false } } to my Vite config seemed to prevent the error. What's confusing is that removing this setting later did not cause the error to reappear until I manually deleted the *.svg file again after putting it back.