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 install
pnpm 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/Linux
Used Package Manager
pnpm
Logs
No response
Validations
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:
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 devIn another terminal, while the dev server is running, execute the following command to simulate removing the asset reference and deleting the file:
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