-
-
Notifications
You must be signed in to change notification settings - Fork 593
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1039 from vuejs/nuxt
Nuxt support. Fix #870. For nuxt/nuxt#4524
- Loading branch information
Showing
4 changed files
with
67 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import * as fs from 'fs'; | ||
import * as path from 'path'; | ||
import { getExternalTagProvider } from './externalTagProviders'; | ||
|
||
const NUXT_VUE_APP_PATH = 'node_modules/@nuxt/vue-app'; | ||
const NUXT_EDGE_VUE_APP_PATH = 'node_modules/@nuxt/vue-app-edge'; | ||
|
||
export function getNuxtTagProvider(workspacePath: string) { | ||
if (fs.existsSync(path.resolve(workspacePath, NUXT_VUE_APP_PATH, 'package.json'))) { | ||
const { nuxtTags, nuxtAttributes } = getNuxtTagsAndAttributes(NUXT_VUE_APP_PATH); | ||
return getExternalTagProvider('nuxt', nuxtTags, nuxtAttributes); | ||
} | ||
|
||
if (fs.existsSync(path.resolve(workspacePath, NUXT_EDGE_VUE_APP_PATH, 'package.json'))) { | ||
const { nuxtTags, nuxtAttributes } = getNuxtTagsAndAttributes(NUXT_EDGE_VUE_APP_PATH); | ||
return getExternalTagProvider('nuxt', nuxtTags, nuxtAttributes); | ||
} | ||
} | ||
|
||
function getNuxtTagsAndAttributes(nuxtVueAppPath: string) { | ||
let nuxtVer = '0.0.0'; | ||
try { | ||
nuxtVer = require(path.resolve(nuxtVueAppPath, 'package.json')).version; | ||
} catch (err) {} | ||
|
||
if (nuxtVer < '2.4.0') { | ||
const nuxtTags = require('nuxt-helper-json/nuxt-tags.json'); | ||
const nuxtAttributes = require('nuxt-helper-json/nuxt-attributes.json'); | ||
|
||
return { | ||
nuxtTags, | ||
nuxtAttributes | ||
}; | ||
} else { | ||
const nuxtTags = require(path.resolve(nuxtVueAppPath, 'vetur/nuxt-tags.json')); | ||
const nuxtAttributes = require(path.resolve(nuxtVueAppPath, 'vetur/nuxt-attributes.json')); | ||
|
||
return { | ||
nuxtTags, | ||
nuxtAttributes | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters