Skip to content

HMR crashes with ENOENT when deleting SVG asset with Vite + Tailwind v4 #19786

Closed

Description

@geomaster

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

  1. pnpm install
  2. 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

Activity

  1. added theissue type on Apr 3, 2025
  2. added
    p3-downstream-blocker
    on Apr 7, 2025
  3. MoperMop commented on Apr 11, 2025

    @MoperMop
    Contributor

    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.

  4. BenzidaneMo commented on Apr 28, 2025

    @BenzidaneMo

    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.

  5. locked and limited conversation to collaborators on Aug 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    contribution welcomefeat: cssp3-downstream-blocker

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions