Skip to content
Open
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,6 @@ playgrounds/vue/auto-imports.d.ts
playgrounds/vue/components.d.ts
playgrounds/vue/tsconfig.app.tsbuildinfo
playgrounds/vue/tsconfig.node.tsbuildinfo

# Test snapshots
__snapshots__/
12 changes: 11 additions & 1 deletion src/plugins/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,20 @@ export default function ComponentImportPlugin(options: NuxtUIOptions & { prefix:
})
const inertiaOverrideNames = new Set(inertiaOverrides.map(c => `${options.prefix}${c.replace(/\.vue$/, '')}`))

const allowlist = [
'@nuxt/ui',
'@compodium/examples',
...(Array.isArray(options.allowedPackages) ? options.allowedPackages : [])
]
const allowlistRegexGroup = allowlist.map(pkg =>
pkg.replace(/\//g, '\\/')
).join('|')
const excludeRegex = new RegExp(`[\\\\/]node_modules[\\\\/](?!\\.pnpm|${allowlistRegexGroup})`)

const pluginOptions = defu(options.components, <ComponentsOptions>{
dts: options.dts ?? true,
exclude: [
/[\\/]node_modules[\\/](?!\.pnpm|@nuxt\/ui|@compodium\/examples)/,
excludeRegex,
/[\\/]\.git[\\/]/,
/[\\/]\.nuxt[\\/]/
],
Expand Down
4 changes: 4 additions & 0 deletions src/unplugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ export interface NuxtUIOptions extends Omit<ModuleOptions, 'fonts' | 'colorMode'
* Enables compatibility layer for InertiaJS
*/
inertia?: boolean
/**
* External packages that should be scanned for Nuxt UI components
*/
allowedPackages?: string[]
}

export const runtimeDir = normalize(fileURLToPath(new URL('./runtime', import.meta.url)))
Expand Down
Loading