mirror of
https://github.com/nuxt/nuxt.git
synced 2025-01-18 17:35:57 +00:00
fix(vite): dev ssr fouc with preprocessors (#1101)
This commit is contained in:
parent
b3ff8eeaed
commit
39ed77e229
@ -3,6 +3,7 @@ import * as vite from 'vite'
|
|||||||
import consola from 'consola'
|
import consola from 'consola'
|
||||||
import vitePlugin from '@vitejs/plugin-vue'
|
import vitePlugin from '@vitejs/plugin-vue'
|
||||||
import viteJsxPlugin from '@vitejs/plugin-vue-jsx'
|
import viteJsxPlugin from '@vitejs/plugin-vue-jsx'
|
||||||
|
import type { Connect } from 'vite'
|
||||||
|
|
||||||
import { cacheDirPlugin } from './plugins/cache-dir'
|
import { cacheDirPlugin } from './plugins/cache-dir'
|
||||||
import { replace } from './plugins/replace'
|
import { replace } from './plugins/replace'
|
||||||
@ -49,7 +50,7 @@ export async function buildClient (ctx: ViteBuildContext) {
|
|||||||
const viteServer = await vite.createServer(clientConfig)
|
const viteServer = await vite.createServer(clientConfig)
|
||||||
await ctx.nuxt.callHook('vite:serverCreated', viteServer)
|
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
|
// Workaround: vite devmiddleware modifies req.url
|
||||||
const originalURL = req.url
|
const originalURL = req.url
|
||||||
viteServer.middlewares.handle(req, res, (err) => {
|
viteServer.middlewares.handle(req, res, (err) => {
|
||||||
|
@ -15,7 +15,7 @@ export function uniq<T> (arr: T[]): T[] {
|
|||||||
return Array.from(new Set(arr))
|
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) {
|
export function isCSS (file: string) {
|
||||||
return IS_CSS_RE.test(file)
|
return IS_CSS_RE.test(file)
|
||||||
|
Loading…
Reference in New Issue
Block a user