mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-25 15:15:19 +00:00
fix(vite): add css to manifest without cssCodeSplit
(#23049)
This commit is contained in:
parent
aa73cbeaf9
commit
411ecabd10
@ -1,5 +1,5 @@
|
||||
import fse from 'fs-extra'
|
||||
import { resolve } from 'pathe'
|
||||
import { relative, resolve } from 'pathe'
|
||||
import { withTrailingSlash, withoutLeadingSlash } from 'ufo'
|
||||
import escapeRE from 'escape-string-regexp'
|
||||
import { normalizeViteManifest } from 'vue-bundle-renderer'
|
||||
@ -47,6 +47,15 @@ export async function writeManifest (ctx: ViteBuildContext, css: string[] = [])
|
||||
|
||||
await fse.mkdirp(serverDist)
|
||||
|
||||
if (ctx.config.build?.cssCodeSplit === false) {
|
||||
const entryCSS = Object.values(clientManifest as Record<string, { file?: string }>).find(val => (val).file?.endsWith('.css'))?.file
|
||||
if (entryCSS) {
|
||||
const key = relative(ctx.config.root!, ctx.entry)
|
||||
clientManifest[key].css ||= []
|
||||
clientManifest[key].css!.push(entryCSS)
|
||||
}
|
||||
}
|
||||
|
||||
const manifest = normalizeViteManifest(clientManifest)
|
||||
await ctx.nuxt.callHook('build:manifest', manifest)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user