From 202ee6e7376a060796872aff5a0639eada299cc5 Mon Sep 17 00:00:00 2001 From: Evan You Date: Thu, 2 Jul 2020 14:22:50 -0400 Subject: [PATCH] fix(dev/css): fix hmr for css referenced in html via `` fix #469 --- src/client/client.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) 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}`)