Skip to content
This repository has been archived by the owner on Apr 6, 2023. It is now read-only.

fix(vite): dev ssr fouc with preprocessors #1101

Merged
merged 2 commits into from
Oct 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/vite/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/vite/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export function uniq<T> (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)
Expand Down