1+ import { readFile } from 'node:fs/promises'
12import {
23 addPlugin ,
34 createResolver ,
45 defineNuxtModule ,
5- extendWebpackConfig , hasNuxtModule ,
6+ extendWebpackConfig ,
7+ hasNuxtModule ,
68 useLogger ,
79} from '@nuxt/kit'
810import type { ViteConfig } from '@nuxt/schema'
911import defu from 'defu'
10- import vuetify from 'vite-plugin-vuetify'
1112import { isPackageExists } from 'local-pkg'
13+ import { resolveVuetifyBase } from '@vuetify/loader-shared'
1214import { version } from '../package.json'
1315import { vuetifyStylesPlugin } from './vite/vuetify-styles-plugin'
1416import type { DateAdapter , ModuleOptions , VOptions } from './types'
1517import { vuetifyConfigurationPlugin } from './vite/vuetify-configuration-plugin'
1618import { vuetifyDateConfigurationPlugin } from './vite/vuetify-date-configuration-plugin'
1719import { prepareIcons } from './utils/icons'
1820import { vuetifyIconsPlugin } from './vite/vuetify-icons-configuration-plugin'
21+ import { toKebabCase } from './utils'
1922
2023export * from './types'
2124
@@ -127,6 +130,26 @@ export default defineNuxtModule<ModuleOptions>({
127130 references . push ( { types : 'vuetify' } )
128131 } )
129132
133+ const vuetifyBase = resolveVuetifyBase ( )
134+ nuxt . hook ( 'components:extend' , async ( c ) => {
135+ const { components } = JSON . parse ( await readFile ( resolver . resolve ( vuetifyBase , 'dist/json/importMap.json' ) , 'utf-8' ) )
136+ Object . keys ( components ) . forEach ( ( component ) => {
137+ const from = components [ component ] . from
138+ c . push ( {
139+ pascalName : component ,
140+ kebabName : toKebabCase ( component ) ,
141+ export : component ,
142+ filePath : `${ resolver . resolve ( vuetifyBase , `lib/${ from } ` ) } ` ,
143+ shortPath : `components/${ from } ` ,
144+ chunkName : toKebabCase ( component ) ,
145+ prefetch : false ,
146+ preload : false ,
147+ global : false ,
148+ mode : 'all' ,
149+ } )
150+ } )
151+ } )
152+
130153 nuxt . hook ( 'vite:extendConfig' , ( viteInlineConfig ) => {
131154 viteInlineConfig . plugins = viteInlineConfig . plugins || [ ]
132155 checkVuetifyPlugins ( viteInlineConfig )
@@ -138,8 +161,7 @@ export default defineNuxtModule<ModuleOptions>({
138161 ...( Array . isArray ( viteInlineConfig . ssr . noExternal ) ? viteInlineConfig . ssr . noExternal : [ ] ) ,
139162 CONFIG_KEY ,
140163 ]
141- const autoImportPlugin = vuetify ( { styles : true , autoImport : true } ) . find ( p => p && typeof p === 'object' && 'name' in p && p . name === 'vuetify:import' ) !
142- viteInlineConfig . plugins . push ( autoImportPlugin )
164+
143165 viteInlineConfig . plugins . push ( vuetifyStylesPlugin ( { styles } , logger ) )
144166 viteInlineConfig . plugins . push ( vuetifyConfigurationPlugin (
145167 nuxt . options . dev ,
0 commit comments