2021-09-27 12:49:36 +00:00
|
|
|
import { resolve } from 'pathe'
|
2022-04-29 18:12:54 +00:00
|
|
|
import { addPlugin, addTemplate, defineNuxtModule } from '@nuxt/kit'
|
2021-08-11 21:26:47 +00:00
|
|
|
import { distDir } from '../dirs'
|
2021-07-15 11:28:04 +00:00
|
|
|
|
|
|
|
export default defineNuxtModule({
|
2022-01-05 18:09:53 +00:00
|
|
|
meta: {
|
|
|
|
name: 'meta'
|
|
|
|
},
|
2021-07-28 11:48:17 +00:00
|
|
|
setup (options, nuxt) {
|
2022-04-05 14:02:29 +00:00
|
|
|
const runtimeDir = nuxt.options.alias['#head'] || resolve(distDir, 'head/runtime')
|
2021-07-15 11:28:04 +00:00
|
|
|
|
2021-08-11 20:28:38 +00:00
|
|
|
// Transpile @nuxt/meta and @vueuse/head
|
2021-10-12 08:39:06 +00:00
|
|
|
nuxt.options.build.transpile.push('@vueuse/head')
|
2021-08-11 20:28:38 +00:00
|
|
|
|
2022-04-05 14:02:29 +00:00
|
|
|
// Add #head alias
|
|
|
|
nuxt.options.alias['#head'] = runtimeDir
|
2021-07-15 11:28:04 +00:00
|
|
|
|
2021-07-28 11:48:17 +00:00
|
|
|
// Add global meta configuration
|
|
|
|
addTemplate({
|
|
|
|
filename: 'meta.config.mjs',
|
2022-08-07 09:53:53 +00:00
|
|
|
getContents: () => 'export default ' + JSON.stringify({ globalMeta: nuxt.options.app.head })
|
2021-07-15 11:28:04 +00:00
|
|
|
})
|
2021-07-28 11:48:17 +00:00
|
|
|
|
|
|
|
// Add generic plugin
|
|
|
|
addPlugin({ src: resolve(runtimeDir, 'plugin') })
|
|
|
|
|
|
|
|
// Add library specific plugin
|
|
|
|
addPlugin({ src: resolve(runtimeDir, 'lib/vueuse-head.plugin') })
|
2021-07-15 11:28:04 +00:00
|
|
|
}
|
|
|
|
})
|