Skip to content

Commit 57a5037

Browse files
committed
fix(vue): handle override when importing from @nuxt/ui
1 parent 752e2b6 commit 57a5037

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

‎src/plugins/components.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { defu } from 'defu'
1111
/**
1212
* This plugin adds all the Nuxt UI components as auto-imports.
1313
*/
14-
export default function ComponentImportPlugin(options: NuxtUIOptions & { prefix: NonNullable<NuxtUIOptions['prefix']> }, meta: UnpluginContextMeta) {
14+
export default function ComponentImportPlugin(options: NuxtUIOptions & { prefix: NonNullable<NuxtUIOptions['prefix']>, extraRuntimeDir?: string }, meta: UnpluginContextMeta) {
1515
const components = globSync('**/*.vue', { cwd: join(runtimeDir, 'components') })
1616
const componentNames = new Set(components.map(c => `${options.prefix}${c.replace(/\.vue$/, '')}`))
1717

@@ -50,13 +50,15 @@ export default function ComponentImportPlugin(options: NuxtUIOptions & { prefix:
5050
name: 'nuxt:ui:components',
5151
enforce: 'pre',
5252
resolveId(id, importer) {
53-
// only apply to runtime nuxt ui components
54-
if (!importer || !normalize(importer).includes(runtimeDir)) {
53+
if (!importer) {
54+
return
55+
}
56+
if (!normalize(importer).includes(runtimeDir) && (!options.extraRuntimeDir || !normalize(importer).includes(options.extraRuntimeDir))) {
5557
return
5658
}
5759

58-
// only apply to relative imports
59-
if (!RELATIVE_IMPORT_RE.test(id)) {
60+
// only apply to relative imports or nuxt ui runtime components
61+
if (!RELATIVE_IMPORT_RE.test(id) && !id.startsWith('@nuxt/ui/components/')) {
6062
return
6163
}
6264

0 commit comments

Comments
 (0)