Skip to content

feat!: change main vuetify plugins logic #184

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions playground/middleware/1.vuetify.global.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export default defineNuxtRouteMiddleware((to) => {
// eslint-disable-next-line no-console
console.log('global middleware', to.path, useNuxtApp().$vuetify)
})
4 changes: 4 additions & 0 deletions playground/middleware/vuetify.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export default defineNuxtRouteMiddleware((to) => {
// eslint-disable-next-line no-console
console.log('middleware', to.path, useNuxtApp().$vuetify)
})
4 changes: 4 additions & 0 deletions playground/pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
import { ssrClientHintsConfiguration } from 'virtual:vuetify-ssr-client-hints-configuration'
import prependAvatar from '~/assets/logo.svg'

definePageMeta({
middleware: 'vuetify',
})

const value = reactive<{
name1?: string
name2?: string
Expand Down
10 changes: 6 additions & 4 deletions src/runtime/plugins/vuetify-sync.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
import type { createVuetify } from 'vuetify'
import { configureVuetify } from './config'
import { defineNuxtPlugin, useNuxtApp } from '#imports'
import { defineNuxtPlugin } from '#imports'
import type { Plugin } from '#app'

const plugin: Plugin<{
vuetify: ReturnType<typeof createVuetify>
}> = defineNuxtPlugin({
name: 'vuetify:configuration:plugin',
enforce: 'post',
// i18n runtime plugin is async
// @ts-expect-error i18n plugin missing on build time
dependsOn: ['i18n:plugin'],
// i18n runtime plugin can be async
parallel: false,
setup() {
useNuxtApp().hook('app:created', configureVuetify)
async setup() {
await configureVuetify()
},
})

Expand Down
6 changes: 3 additions & 3 deletions src/runtime/plugins/vuetify.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import type { createVuetify } from 'vuetify'
import { configureVuetify } from './config'
import { defineNuxtPlugin, useNuxtApp } from '#imports'
import { defineNuxtPlugin } from '#imports'
import type { Plugin } from '#app'

const plugin: Plugin<{
vuetify: ReturnType<typeof createVuetify>
}> = defineNuxtPlugin({
name: 'vuetify:configuration:plugin',
enforce: 'post',
setup() {
useNuxtApp().hook('app:created', configureVuetify)
async setup() {
await configureVuetify()
},
})

Expand Down