Skip to content

Commit

Permalink
fix: vuetify nuxt plugin cannot resolve imports (#187)
Browse files Browse the repository at this point in the history
  • Loading branch information
userquin authored Jan 12, 2024
1 parent b47930b commit 5042913
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 41 deletions.
4 changes: 1 addition & 3 deletions src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
26 changes: 0 additions & 26 deletions src/runtime/plugins/config.ts

This file was deleted.

27 changes: 15 additions & 12 deletions src/utils/configure-nuxt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<typeof createVuetify>
}> = 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
`
},
})
Expand Down

0 comments on commit 5042913

Please sign in to comment.