Skip to content
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
23 changes: 23 additions & 0 deletions docs/content/docs/1.getting-started/2.installation/2.vue.md
Original file line number Diff line number Diff line change
Expand Up @@ -725,6 +725,29 @@ export default defineConfig({
When using this option, `vue-router` is not required as Inertia.js provides its own routing system. The components that would normally use `RouterLink` will automatically use Inertia's `InertiaLink` component instead.
::

### `scanPackages`

Use the `scanPackages` option to specify additional npm packages that should be scanned for components using Nuxt UI. This is useful when you have a shared component library that uses Nuxt UI components internally.

```ts [vite.config.ts] {9}
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import ui from '@nuxt/ui/vite'

export default defineConfig({
plugins: [
vue(),
ui({
scanPackages: ['@my-org/ui-components']
})
]
})
```

::note
By default, only `@nuxt/ui` is scanned. Use this option when your external packages contain Vue components that use Nuxt UI.
::

## Continuous releases

Nuxt UI uses [pkg.pr.new](https://github.com/stackblitz-labs/pkg.pr.new) for continuous preview releases, providing developers with instant access to the latest features and bug fixes without waiting for official releases.
Expand Down
11 changes: 10 additions & 1 deletion src/plugins/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,19 @@ export default function ComponentImportPlugin(options: NuxtUIOptions & { prefix:
})
const inertiaOverrideNames = new Set(inertiaOverrides.map(c => `${options.prefix}${c.replace(/\.vue$/, '')}`))

const packagesToScan = [
'@nuxt/ui',
'@compodium/examples',
...(Array.isArray(options.scanPackages) ? options.scanPackages : [])
]
const escapeRegex = (str: string) => str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
const packagesRegex = packagesToScan.map(escapeRegex).join('|')
const excludeRegex = new RegExp(`[\\\\/]node_modules[\\\\/](?!\\.pnpm|${packagesRegex})`)

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
/**
* Additional packages to scan for components using Nuxt UI
*/
scanPackages?: string[]
}

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