diff --git a/packages/kit/src/components.ts b/packages/kit/src/components.ts index e344b7a95a..365bf514af 100644 --- a/packages/kit/src/components.ts +++ b/packages/kit/src/components.ts @@ -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