fix(kit): properly read nuxt version (resolves #616)

This commit is contained in:
Pooya Parsa 2021-10-02 18:19:36 +02:00
parent 6e496373f3
commit bba79f4836

View File

@ -259,7 +259,9 @@ export function addVitePlugin (plugin: VitePlugin, options?: ExtendViteConfigOpt
* Check if current nuxt instance is version 2 legacy * Check if current nuxt instance is version 2 legacy
*/ */
export function isNuxt2 (nuxt?: any) { export function isNuxt2 (nuxt?: any) {
return (nuxt || useNuxt()).version?.startsWith('v2') nuxt = nuxt || useNuxt()
const version = (nuxt?.version || nuxt?.constructor?.version || '').replace(/^v|-.*$/g, '')
return version.startsWith('2.')
} }
export async function compileTemplate (template: NuxtTemplate, ctx: any) { export async function compileTemplate (template: NuxtTemplate, ctx: any) {