mirror of
https://github.com/nuxt/nuxt.git
synced 2025-01-18 09:25:54 +00:00
24 lines
820 B
TypeScript
24 lines
820 B
TypeScript
import type { AutoImport } from '../../schema/src/types/imports'
|
|
import { useNuxt } from './context'
|
|
import { assertNuxtCompatibility } from './compatibility'
|
|
|
|
export function addAutoImport (_autoImports: AutoImport | AutoImport[]) {
|
|
assertNuxtCompatibility({ bridge: true })
|
|
|
|
useNuxt().hook('autoImports:extend', (autoImports: AutoImport[]) => {
|
|
for (const composable of (Array.isArray(_autoImports) ? _autoImports : [_autoImports])) {
|
|
autoImports.push(composable)
|
|
}
|
|
})
|
|
}
|
|
|
|
export function addAutoImportDir (_autoImportDirs: string | string[]) {
|
|
assertNuxtCompatibility({ bridge: true })
|
|
|
|
useNuxt().hook('autoImports:dirs', (autoImportDirs: string[]) => {
|
|
for (const dir of (Array.isArray(_autoImportDirs) ? _autoImportDirs : [_autoImportDirs])) {
|
|
autoImportDirs.push(dir)
|
|
}
|
|
})
|
|
}
|