feat(nuxt3): support async function as nuxt.config (#1612)

This commit is contained in:
Tasuku Uno 2021-11-02 18:37:48 +09:00 committed by GitHub
parent 8838cc7192
commit a8b969a4dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -33,6 +33,11 @@ export async function loadNuxtConfig (opts: LoadNuxtConfigOptions): Promise<Nuxt
if (nuxtConfigFile && existsSync(nuxtConfigFile)) { if (nuxtConfigFile && existsSync(nuxtConfigFile)) {
nuxtConfig = requireModule(nuxtConfigFile, { clearCache: true }) nuxtConfig = requireModule(nuxtConfigFile, { clearCache: true })
if (typeof nuxtConfig === 'function') {
nuxtConfig = await nuxtConfig(opts)
}
nuxtConfig = { ...nuxtConfig } nuxtConfig = { ...nuxtConfig }
nuxtConfig._nuxtConfigFile = nuxtConfigFile nuxtConfig._nuxtConfigFile = nuxtConfigFile
nuxtConfig._nuxtConfigFiles = Array.from(scanRequireTree(nuxtConfigFile)) nuxtConfig._nuxtConfigFiles = Array.from(scanRequireTree(nuxtConfigFile))