mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-24 22:55:13 +00:00
fix(vite): omit css ?raw
from head when in dev mode (#27940)
This commit is contained in:
parent
5ac6aa574a
commit
0f684970e9
@ -8,7 +8,7 @@ import { normalizeViteManifest } from 'vue-bundle-renderer'
|
||||
import type { Manifest } from 'vue-bundle-renderer'
|
||||
import type { ViteBuildContext } from './vite'
|
||||
|
||||
export async function writeManifest (ctx: ViteBuildContext, css: string[] = []) {
|
||||
export async function writeManifest (ctx: ViteBuildContext) {
|
||||
// Write client manifest for use in vue-bundle-renderer
|
||||
const clientDist = resolve(ctx.nuxt.options.buildDir, 'dist/client')
|
||||
const serverDist = resolve(ctx.nuxt.options.buildDir, 'dist/server')
|
||||
@ -17,7 +17,7 @@ export async function writeManifest (ctx: ViteBuildContext, css: string[] = [])
|
||||
'@vite/client': {
|
||||
isEntry: true,
|
||||
file: '@vite/client',
|
||||
css,
|
||||
css: [],
|
||||
module: true,
|
||||
resourceType: 'script',
|
||||
},
|
||||
|
@ -6,6 +6,7 @@ import { isAbsolute, normalize, resolve } from 'pathe'
|
||||
import { addDevServerHandler } from '@nuxt/kit'
|
||||
import { isFileServingAllowed } from 'vite'
|
||||
import type { ModuleNode, Plugin as VitePlugin } from 'vite'
|
||||
import { getQuery } from 'ufo'
|
||||
import { normalizeViteManifest } from 'vue-bundle-renderer'
|
||||
import { resolve as resolveModule } from 'mlly'
|
||||
import { distDir } from './dirs'
|
||||
@ -78,13 +79,23 @@ export function registerViteNodeMiddleware (ctx: ViteBuildContext) {
|
||||
}
|
||||
|
||||
function getManifest (ctx: ViteBuildContext) {
|
||||
const css = Array.from(ctx.ssrServer!.moduleGraph.urlToModuleMap.keys())
|
||||
.filter(i => isCSS(i))
|
||||
const css = new Set<string>()
|
||||
for (const key of ctx.ssrServer!.moduleGraph.urlToModuleMap.keys()) {
|
||||
if (isCSS(key)) {
|
||||
const query = getQuery(key)
|
||||
if ('raw' in query) { continue }
|
||||
const importers = ctx.ssrServer!.moduleGraph.urlToModuleMap.get(key)?.importers
|
||||
if (importers && [...importers].every(i => i.id && 'raw' in getQuery(i.id))) {
|
||||
continue
|
||||
}
|
||||
css.add(key)
|
||||
}
|
||||
}
|
||||
|
||||
const manifest = normalizeViteManifest({
|
||||
'@vite/client': {
|
||||
file: '@vite/client',
|
||||
css,
|
||||
css: [...css],
|
||||
module: true,
|
||||
isEntry: true,
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user