Skip to content

fix(hmr): don't try to rewrite imports for direct CSS soft invalidation#18252

Merged
bluwy merged 2 commits intovitejs:mainfrom
sapphi-red:fix/dont-try-to-rewrite-imports-for-direct-css-softinvalidation
Oct 4, 2024
Merged

fix(hmr): don't try to rewrite imports for direct CSS soft invalidation#18252
bluwy merged 2 commits intovitejs:mainfrom
sapphi-red:fix/dont-try-to-rewrite-imports-for-direct-css-softinvalidation

Conversation

@sapphi-red
Copy link
Copy Markdown
Member

Description

When a direct CSS is soft invalidated and has a content that fails to parse by es-module-lexer (this only happens some times as ex-module-lexer is quite relax with invalid syntaxes), Vite failed to load that file after a refresh.

A direct CSS file is soft invalidated when the file depends on a JS file. This happens if a file included in tailwind's content option is updated. For example, the reproduction in the issue has assets/custom.css and is imported by app.vue and that is included by tailwind's content option.

fixes nuxt/nuxt#26454

@sapphi-red sapphi-red added feat: css feat: hmr p3-downstream-blocker Blocking the downstream ecosystem to work properly (priority) labels Oct 2, 2024
@bolt-new-by-stackblitz
Copy link
Copy Markdown

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@sapphi-red sapphi-red force-pushed the fix/dont-try-to-rewrite-imports-for-direct-css-softinvalidation branch from b6d969e to cb40cb5 Compare October 2, 2024 01:38
Comment thread packages/vite/src/node/server/transformRequest.ts Outdated
@bluwy bluwy merged commit a03bb0e into vitejs:main Oct 4, 2024
@sapphi-red sapphi-red deleted the fix/dont-try-to-rewrite-imports-for-direct-css-softinvalidation branch October 4, 2024 15:56
moonlitusun pushed a commit to moonlitusun/vite that referenced this pull request May 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feat: css feat: hmr p3-downstream-blocker Blocking the downstream ecosystem to work properly (priority)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CSS HMR errors from Tailwind arbitrary value classes

2 participants