mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-11 08:33:53 +00:00
fix: bring back nuxt3 support
This commit is contained in:
parent
b07a4a5c8d
commit
9e9b20ef90
@ -38,6 +38,7 @@ export interface SigmaContext {
|
||||
publicDir: string
|
||||
}
|
||||
_nuxt: {
|
||||
majorVersion: number
|
||||
dev: boolean
|
||||
rootDir: string
|
||||
srcDir: string
|
||||
@ -88,6 +89,7 @@ export function getsigmaContext (nuxtOptions: NuxtOptions, input: SigmaInput): S
|
||||
publicDir: '{{ output.dir }}/public'
|
||||
},
|
||||
_nuxt: {
|
||||
majorVersion: nuxtOptions._majorVersion || 2,
|
||||
dev: nuxtOptions.dev,
|
||||
rootDir: nuxtOptions.rootDir,
|
||||
srcDir: nuxtOptions.srcDir,
|
||||
|
@ -159,13 +159,13 @@ export const getRollupConfig = (sigmaContext: SigmaContext) => {
|
||||
}))
|
||||
|
||||
// https://github.com/rollup/plugins/tree/master/packages/alias
|
||||
const renderer = sigmaContext.renderer || 'vue2'
|
||||
const vueServerRenderer = 'vue-server-renderer/' + (sigmaContext._nuxt.dev ? 'build.dev.js' : 'build.prod.js')
|
||||
const renderer = sigmaContext.renderer || (sigmaContext._nuxt.majorVersion === 3 ? 'vue3' : 'vue2')
|
||||
const vue2ServerRenderer = 'vue-server-renderer/' + (sigmaContext._nuxt.dev ? 'build.dev.js' : 'build.prod.js')
|
||||
rollupConfig.plugins.push(alias({
|
||||
entries: {
|
||||
'~runtime': sigmaContext._internal.runtimeDir,
|
||||
'~renderer': require.resolve(resolve(sigmaContext._internal.runtimeDir, 'app', renderer)),
|
||||
'~vueServerRenderer': vueServerRenderer,
|
||||
'~vueServerRenderer': vue2ServerRenderer,
|
||||
'~build': sigmaContext._nuxt.buildDir,
|
||||
...env.alias
|
||||
}
|
||||
|
@ -33,7 +33,8 @@ export async function renderMiddleware (req, res) {
|
||||
...(req.context || {})
|
||||
}
|
||||
const rendered = await renderer.renderToString(ssrContext)
|
||||
const payload = ssrContext.nuxt /* nuxt 2 */ || ssrContext.payload /* nuxt 3 */
|
||||
// TODO: nuxt3 should not reuse `nuxt` property for different purpose!
|
||||
const payload = ssrContext.payload /* nuxt 3 */ || ssrContext.nuxt /* nuxt 2 */
|
||||
|
||||
if (process.env.NUXT_FULL_STATIC) {
|
||||
payload.staticAssetsBase = STATIC_ASSETS_BASE
|
||||
|
Loading…
Reference in New Issue
Block a user