From 0c4225238a54e6e1f94bac7b1c0a6b304af66ff7 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Mon, 2 Nov 2020 13:50:40 +0100 Subject: [PATCH] configurable nuxt version --- packages/nitro/src/nuxt-deploy.ts | 3 ++- packages/nitro/src/rollup.config.ts | 1 + packages/nitro/src/runtime/server.ts | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/nitro/src/nuxt-deploy.ts b/packages/nitro/src/nuxt-deploy.ts index f69ae9c320..dd0633295f 100644 --- a/packages/nitro/src/nuxt-deploy.ts +++ b/packages/nitro/src/nuxt-deploy.ts @@ -18,6 +18,7 @@ async function main () { rootDir, buildDir: '', targets: [], + nuxt: 2, target: process.argv[3] && process.argv[3][0] !== '-' ? process.argv[3] : null, minify: process.argv.includes('--minify') ? true : null, analyze: process.argv.includes('--analyze') ? true : null, @@ -37,7 +38,7 @@ async function main () { process.chdir(config.buildDir) // Compile html template - const htmlTemplateFile = resolve(config.buildDir, 'views/app.template.html') // TODO: nuxt3: document.template.html + const htmlTemplateFile = resolve(config.buildDir, `views/${{ 2: 'app', 3: 'template' }[config.nuxt]}.template.html`) const htmlTemplateFileJS = htmlTemplateFile.replace(/.html$/, '.js').replace('app.', 'document.') const htmlTemplateContents = await readFile(htmlTemplateFile, 'utf-8') // eslint-disable-next-line no-template-curly-in-string diff --git a/packages/nitro/src/rollup.config.ts b/packages/nitro/src/rollup.config.ts index 450fbaffe0..8e93be3620 100644 --- a/packages/nitro/src/rollup.config.ts +++ b/packages/nitro/src/rollup.config.ts @@ -64,6 +64,7 @@ export const getRollupConfig = (config) => { options.plugins.push(alias({ entries: { '~runtime': path.resolve(__dirname, 'runtime'), + '~rendertostring': config.nuxt === 2 ? require.resolve('./runtime/vue2') : require.resolve('./runtime/vue3'), '~build': config.buildDir, '~mock': require.resolve('./runtime/mock'), ...mocks.reduce((p, c) => ({ ...p, [c]: '~mock' }), {}) diff --git a/packages/nitro/src/runtime/server.ts b/packages/nitro/src/runtime/server.ts index 84fdaf0aab..f83c1b73a4 100644 --- a/packages/nitro/src/runtime/server.ts +++ b/packages/nitro/src/runtime/server.ts @@ -2,7 +2,7 @@ import { createRenderer } from 'vue-bundle-renderer' import devalue from '@nuxt/devalue' // @ts-ignore -import { renderToString } from './vue2' +import { renderToString } from '~rendertostring' // @ts-ignore import server from '~build/dist/server/server' // @ts-ignore