mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-25 15:15:19 +00:00
fix(vite): write dev manifest when ssr: false
(#28488)
This commit is contained in:
parent
fb2d7b94cd
commit
4eef63469b
@ -8,12 +8,29 @@ import { normalizeViteManifest } from 'vue-bundle-renderer'
|
|||||||
import type { ViteBuildContext } from './vite'
|
import type { ViteBuildContext } from './vite'
|
||||||
|
|
||||||
export async function writeManifest (ctx: ViteBuildContext) {
|
export async function writeManifest (ctx: ViteBuildContext) {
|
||||||
|
// This is only used for ssr: false - when ssr is enabled we use vite-node runtime manifest
|
||||||
|
const devClientManifest = {
|
||||||
|
'@vite/client': {
|
||||||
|
isEntry: true,
|
||||||
|
file: '@vite/client',
|
||||||
|
css: [],
|
||||||
|
module: true,
|
||||||
|
resourceType: 'script',
|
||||||
|
},
|
||||||
|
[ctx.entry]: {
|
||||||
|
isEntry: true,
|
||||||
|
file: ctx.entry,
|
||||||
|
module: true,
|
||||||
|
resourceType: 'script',
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
// Write client manifest for use in vue-bundle-renderer
|
// Write client manifest for use in vue-bundle-renderer
|
||||||
const clientDist = resolve(ctx.nuxt.options.buildDir, 'dist/client')
|
const clientDist = resolve(ctx.nuxt.options.buildDir, 'dist/client')
|
||||||
const serverDist = resolve(ctx.nuxt.options.buildDir, 'dist/server')
|
const serverDist = resolve(ctx.nuxt.options.buildDir, 'dist/server')
|
||||||
|
|
||||||
const manifestFile = resolve(clientDist, 'manifest.json')
|
const manifestFile = resolve(clientDist, 'manifest.json')
|
||||||
const clientManifest = JSON.parse(readFileSync(manifestFile, 'utf-8'))
|
const clientManifest = ctx.nuxt.options.dev ? devClientManifest : JSON.parse(readFileSync(manifestFile, 'utf-8'))
|
||||||
|
|
||||||
const buildAssetsDir = withTrailingSlash(withoutLeadingSlash(ctx.nuxt.options.app.buildAssetsDir))
|
const buildAssetsDir = withTrailingSlash(withoutLeadingSlash(ctx.nuxt.options.app.buildAssetsDir))
|
||||||
const BASE_RE = new RegExp(`^${escapeRE(buildAssetsDir)}`)
|
const BASE_RE = new RegExp(`^${escapeRE(buildAssetsDir)}`)
|
||||||
|
@ -148,6 +148,7 @@ export async function buildServer (ctx: ViteBuildContext) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!ctx.nuxt.options.ssr) {
|
if (!ctx.nuxt.options.ssr) {
|
||||||
|
await writeManifest(ctx)
|
||||||
await onBuild()
|
await onBuild()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user