mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-26 23:52:06 +00:00
22 lines
699 B
TypeScript
22 lines
699 B
TypeScript
import { Import } from 'unimport'
|
|
import { useNuxt } from './context'
|
|
import { assertNuxtCompatibility } from './compatibility'
|
|
|
|
export function addAutoImport (imports: Import | Import[]) {
|
|
assertNuxtCompatibility({ bridge: true })
|
|
|
|
useNuxt().hook('autoImports:extend', (autoImports) => {
|
|
autoImports.push(...(Array.isArray(imports) ? imports : [imports]))
|
|
})
|
|
}
|
|
|
|
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)
|
|
}
|
|
})
|
|
}
|