diff --git a/src/client/client.ts b/src/client/client.ts index 5448bf703e7386..7901c997a69f99 100644 --- a/src/client/client.ts +++ b/src/client/client.ts @@ -108,6 +108,17 @@ async function handleMessage(payload: HMRPayload) { }) break case 'style-update': + // check if this is referenced in html via + const el = document.querySelector(`link[href*='${path}']`) + if (el) { + bustSwCache(path) + el.setAttribute( + 'href', + `${path}${path.includes('?') ? '&' : '?'}t=${timestamp}` + ) + break + } + // imported CSS const importQuery = path.includes('?') ? '&import' : '?import' bustSwCache(`${path}${importQuery}`) await import(`${path}${importQuery}&t=${timestamp}`)