From d413848afcec0dcce998f2f33f341f0e620addfa Mon Sep 17 00:00:00 2001 From: Jevon <1787176370@qq.com> Date: Tue, 22 Nov 2022 22:29:56 +0800 Subject: [PATCH] fix(plugin-vue): support scss/sass/less... hmr on custom template languages (fix #10677) (#10844) --- packages/plugin-vue/src/handleHotUpdate.ts | 4 +++- packages/vite/src/node/publicUtils.ts | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/plugin-vue/src/handleHotUpdate.ts b/packages/plugin-vue/src/handleHotUpdate.ts index d1d4ae9f089ee8..5569f0dfbe02ae 100644 --- a/packages/plugin-vue/src/handleHotUpdate.ts +++ b/packages/plugin-vue/src/handleHotUpdate.ts @@ -1,6 +1,8 @@ import _debug from 'debug' import type { SFCBlock, SFCDescriptor } from 'vue/compiler-sfc' import type { HmrContext, ModuleNode } from 'vite' +import { isCSSRequest } from 'vite' + import { createDescriptor, getDescriptor, @@ -153,7 +155,7 @@ export async function handleHotUpdate( affectedModules.add(mainModule) } else if (mainModule && !affectedModules.has(mainModule)) { const styleImporters = [...mainModule.importers].filter((m) => - /\.css(?:$|\?)/.test(m.url) + isCSSRequest(m.url) ) styleImporters.forEach((m) => affectedModules.add(m)) } diff --git a/packages/vite/src/node/publicUtils.ts b/packages/vite/src/node/publicUtils.ts index 5bf523a87f5799..f6cc21ca9243ff 100644 --- a/packages/vite/src/node/publicUtils.ts +++ b/packages/vite/src/node/publicUtils.ts @@ -8,7 +8,8 @@ export { version as esbuildVersion } from 'esbuild' export { VERSION as rollupVersion } from 'rollup' export { splitVendorChunkPlugin, - splitVendorChunk + splitVendorChunk, + isCSSRequest } from './plugins/splitVendorChunk' export { normalizePath, mergeConfig, mergeAlias, createFilter } from './utils' export { send } from './server/send'