Nuxt/test/fixtures/basic/modules/example.ts
Inesh Bose 98d292ae85
fix(nuxt): provide types for modules as array (#18416)
Co-authored-by: Daniel Roe <daniel@roe.dev>
2023-01-21 16:55:44 +00:00

24 lines
620 B
TypeScript

import { fileURLToPath } from 'node:url'
import { defineNuxtModule, addPlugin, useNuxt } from '@nuxt/kit'
export default defineNuxtModule({
defaults: {
enabled: true,
typeTest: (value: boolean) => typeof value === 'boolean'
},
meta: {
name: 'my-module',
configKey: 'sampleModule'
},
setup () {
addPlugin(fileURLToPath(new URL('./runtime/plugin', import.meta.url)))
useNuxt().hook('app:resolve', (app) => {
app.middleware.push({
name: 'unctx-test',
path: fileURLToPath(new URL('./runtime/middleware', import.meta.url)),
global: true
})
})
}
})