diff --git a/packages/vite/src/client.ts b/packages/vite/src/client.ts index fd12ab48d8f..c21c47cb4db 100644 --- a/packages/vite/src/client.ts +++ b/packages/vite/src/client.ts @@ -3,6 +3,7 @@ import * as vite from 'vite' import consola from 'consola' import vitePlugin from '@vitejs/plugin-vue' import viteJsxPlugin from '@vitejs/plugin-vue-jsx' +import type { Connect } from 'vite' import { cacheDirPlugin } from './plugins/cache-dir' import { replace } from './plugins/replace' @@ -49,7 +50,7 @@ export async function buildClient (ctx: ViteBuildContext) { const viteServer = await vite.createServer(clientConfig) await ctx.nuxt.callHook('vite:serverCreated', viteServer) - const viteMiddleware = (req, res, next) => { + const viteMiddleware: Connect.NextHandleFunction = (req, res, next) => { // Workaround: vite devmiddleware modifies req.url const originalURL = req.url viteServer.middlewares.handle(req, res, (err) => { diff --git a/packages/vite/src/utils.ts b/packages/vite/src/utils.ts index 5466159941d..015e0efe317 100644 --- a/packages/vite/src/utils.ts +++ b/packages/vite/src/utils.ts @@ -15,7 +15,7 @@ export function uniq (arr: T[]): T[] { return Array.from(new Set(arr)) } -const IS_CSS_RE = /\.css(\?[^.]+)?$/ +const IS_CSS_RE = /\.(?:css|scss|sass|postcss|less|stylus|styl)(\?[^.]+)?$/ export function isCSS (file: string) { return IS_CSS_RE.test(file)