mirror of
https://github.com/nuxt/nuxt.git
synced 2025-01-30 23:32:38 +00:00
feat(kit): support prepend option for addComponentsDir
(#24309)
This commit is contained in:
parent
4ce6bc244c
commit
be11bac9c2
@ -9,12 +9,12 @@ import { logger } from './logger'
|
||||
*
|
||||
* Requires Nuxt 2.13+
|
||||
*/
|
||||
export async function addComponentsDir (dir: ComponentsDir) {
|
||||
export async function addComponentsDir (dir: ComponentsDir, opts: { prepend?: boolean } = {}) {
|
||||
const nuxt = useNuxt()
|
||||
await assertNuxtCompatibility({ nuxt: '>=2.13' }, nuxt)
|
||||
nuxt.options.components = nuxt.options.components || []
|
||||
dir.priority ||= 0
|
||||
nuxt.hook('components:dirs', (dirs) => { dirs.push(dir) })
|
||||
nuxt.hook('components:dirs', (dirs) => { dirs[opts.prepend ? 'unshift' : 'push'](dir) })
|
||||
}
|
||||
|
||||
export type AddComponentOptions = { name: string, filePath: string } & Partial<Exclude<Component,
|
||||
|
Loading…
Reference in New Issue
Block a user