Skip to content

Commit

Permalink
fix(hmr/css): check CSS importers for hmr boundaries - fix Tailwind 2…
Browse files Browse the repository at this point in the history
….2 compat
  • Loading branch information
yyx990803 committed Jun 18, 2021
1 parent 385ced9 commit 6eaec3a
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions packages/vite/src/node/server/hmr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { RollupError } from 'rollup'
import { prepareError } from './middlewares/error'
import match from 'minimatch'
import { Server } from 'http'
import { isCSSRequest } from '../plugins/css'

export const debugHmr = createDebugger('vite:hmr')

Expand Down Expand Up @@ -222,6 +223,20 @@ function propagateUpdate(
boundary: node,
acceptedVia: node
})

// additionally check for CSS importers, since a PostCSS plugin like
// Tailwind JIT may register any file as a dependency to a CSS file.
for (const importer of node.importers) {
if (isCSSRequest(importer.url)) {
propagateUpdate(
importer,
timestamp,
boundaries,
currentChain.concat(importer)
)
}
}

return false
}

Expand Down

0 comments on commit 6eaec3a

Please sign in to comment.