From 16aa8871421847de51da8f5d4797c1960074c14d Mon Sep 17 00:00:00 2001 From: Anthony Fu Date: Wed, 27 Oct 2021 13:36:58 +0800 Subject: [PATCH] fix(plugin-vue): exclude direct css request from hmr target (#5422) --- packages/plugin-vue/src/handleHotUpdate.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/plugin-vue/src/handleHotUpdate.ts b/packages/plugin-vue/src/handleHotUpdate.ts index 32da6125..88f44a37 100644 --- a/packages/plugin-vue/src/handleHotUpdate.ts +++ b/packages/plugin-vue/src/handleHotUpdate.ts @@ -11,6 +11,8 @@ import { ResolvedOptions } from '.' const debug = _debug('vite:hmr') +const directRequestRE = /(\?|&)direct\b/ + /** * Vite-specific HMR handling */ @@ -92,7 +94,8 @@ export async function handleHotUpdate( const mod = modules.find( (m) => m.url.includes(`type=style&index=${i}`) && - m.url.endsWith(`.${next.lang || 'css'}`) + m.url.endsWith(`.${next.lang || 'css'}`) && + !directRequestRE.test(m.url) ) if (mod) { affectedModules.add(mod)