diff --git a/src/module.ts b/src/module.ts index a4b1d25..cd2b235 100644 --- a/src/module.ts +++ b/src/module.ts @@ -91,9 +91,7 @@ export interface ModuleHooks { 'vuetify:registerModule': (registerModule: (config: InlineModuleOptions) => void) => HookResult } -// rename this to ModuleRuntimeHooks when released: -// https://github.com/nuxt/module-builder/pull/194 -export interface RuntimeModuleHooks { +export interface ModuleRuntimeHooks { 'vuetify:configuration': (options: { isDev: boolean vuetifyOptions: VuetifyOptions diff --git a/src/runtime/plugins/config.ts b/src/runtime/plugins/config.ts deleted file mode 100644 index b0c9892..0000000 --- a/src/runtime/plugins/config.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { createVuetify } from 'vuetify' -import { isDev, vuetifyConfiguration } from 'virtual:vuetify-configuration' -import { useNuxtApp } from '#imports' - -export async function configureVuetify() { - const nuxtApp = useNuxtApp() - const vuetifyOptions = vuetifyConfiguration() - - await nuxtApp.hooks.callHook('vuetify:configuration', { isDev, vuetifyOptions }) - - await nuxtApp.hooks.callHook('vuetify:before-create', { isDev, vuetifyOptions }) - - const vuetify = createVuetify(vuetifyOptions) - - nuxtApp.vueApp.use(vuetify) - - nuxtApp.provide('vuetify', vuetify) - - await nuxtApp.hooks.callHook('vuetify:ready', vuetify) - - // eslint-disable-next-line n/prefer-global/process - if (process.client) { - // eslint-disable-next-line no-console - isDev && console.log('Vuetify 3 initialized', vuetify) - } -} diff --git a/src/utils/configure-nuxt.ts b/src/utils/configure-nuxt.ts index e991ccc..928c71e 100644 --- a/src/utils/configure-nuxt.ts +++ b/src/utils/configure-nuxt.ts @@ -134,31 +134,34 @@ dependsOn.push('vuetify:client-hints:server:plugin') } addPluginTemplate({ - filename: 'vuetify-nuxt-plugin.ts', + filename: 'vuetify-nuxt-plugin.mjs', write: false, getContents() { return ` -import type { createVuetify } from 'vuetify' -import { configureVuetify } from 'vuetify-nuxt-module/dist/runtime/plugins/config' import { defineNuxtPlugin } from '#imports' -import type { Plugin } from '#app' +import { isDev, vuetifyConfiguration } from 'virtual:vuetify-configuration' +import { createVuetify } from 'vuetify' const dependsOn = ${JSON.stringify(dependsOn)} ${addHttpClientHintsPlugin} -const plugin: Plugin<{ - vuetify: ReturnType -}> = defineNuxtPlugin({ - name: 'vuetify:configuration:plugin', +export default defineNuxtPlugin({ + name: 'vuetify:nuxt:plugin', order: 25, dependsOn, parallel: true, - async setup() { - await configureVuetify() + async setup(nuxtApp) { + const vuetifyOptions = vuetifyConfiguration() + await nuxtApp.hooks.callHook('vuetify:configuration', { isDev, vuetifyOptions }) + await nuxtApp.hooks.callHook('vuetify:before-create', { isDev, vuetifyOptions }) + const vuetify = createVuetify(vuetifyOptions) + nuxtApp.vueApp.use(vuetify) + nuxtApp.provide('vuetify', vuetify) + await nuxtApp.hooks.callHook('vuetify:ready', vuetify) + if (process.client) + isDev && console.log('Vuetify 3 initialized', vuetify) }, }) - -export default plugin ` }, })