Skip to content

Commit 851b258

Browse files
committed
fix(hmr): don't try to rewrite imports for direct CSS soft invalidation (#18252)
1 parent 96084d6 commit 851b258

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

packages/vite/src/node/server/moduleGraph.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,10 @@ export class ModuleGraph {
229229
// to only update the import timestamps. If it's not statically imported, e.g. watched/glob file,
230230
// we can only soft invalidate if the current module was also soft-invalidated. A soft-invalidation
231231
// doesn't need to trigger a re-load and re-transform of the importer.
232+
// But we exclude direct CSS files as those cannot be soft invalidated.
232233
const shouldSoftInvalidateImporter =
233-
importer.staticImportedUrls?.has(mod.url) || softInvalidate
234+
(importer.staticImportedUrls?.has(mod.url) || softInvalidate) &&
235+
importer.type !== 'css'
234236
this.invalidateModule(
235237
importer,
236238
seen,

0 commit comments

Comments
 (0)