configurable nuxt version

This commit is contained in:
Pooya Parsa 2020-11-02 13:50:40 +01:00
parent 54bb617474
commit 0c4225238a
3 changed files with 4 additions and 2 deletions

View File

@ -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

View File

@ -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' }), {})

View File

@ -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