mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-22 05:35:13 +00:00
feat(nuxt, kit): auto import defineNuxtConfig
(#7497)
This commit is contained in:
parent
aaac46980c
commit
ac0b3a63a2
@ -7,6 +7,7 @@ import { NuxtConfigSchema } from '@nuxt/schema'
|
||||
export interface LoadNuxtConfigOptions extends LoadConfigOptions<NuxtConfig> {}
|
||||
|
||||
export async function loadNuxtConfig (opts: LoadNuxtConfigOptions): Promise<NuxtOptions> {
|
||||
(globalThis as any).defineNuxtConfig = (c: any) => c
|
||||
const result = await loadConfig<NuxtConfig>({
|
||||
name: 'nuxt',
|
||||
configFile: 'nuxt.config',
|
||||
@ -16,6 +17,7 @@ export async function loadNuxtConfig (opts: LoadNuxtConfigOptions): Promise<Nuxt
|
||||
globalRc: true,
|
||||
...opts
|
||||
})
|
||||
delete (globalThis as any).defineNuxtConfig
|
||||
const { configFile, layers = [], cwd } = result
|
||||
const nuxtConfig = result.config!
|
||||
|
||||
|
@ -234,10 +234,11 @@ export async function loadNuxt (opts: LoadNuxtOptions): Promise<Nuxt> {
|
||||
return nuxt
|
||||
}
|
||||
|
||||
/** @deprecated Use import { defineNuxtConfig } from 'nuxt/config' */
|
||||
/** @deprecated `defineNuxtConfig` is auto imported. Remove import or alternatively use `import { defineNuxtConfig } from 'nuxt/config'`. */
|
||||
export function defineNuxtConfig (config: NuxtConfig): NuxtConfig {
|
||||
return config
|
||||
}
|
||||
|
||||
/** @deprecated Use import type { NuxtConfig } from 'nuxt/config' */
|
||||
export type { NuxtConfig }
|
||||
/** @deprecated Use `import type { NuxtConfig } from 'nuxt/config'`. */
|
||||
type _NuxtConfig = NuxtConfig
|
||||
export type { _NuxtConfig as NuxtConfig }
|
||||
|
4
packages/nuxt/types.d.ts
vendored
4
packages/nuxt/types.d.ts
vendored
@ -1,2 +1,6 @@
|
||||
/// <reference types="nitropack" />
|
||||
export * from './dist/index'
|
||||
|
||||
declare global {
|
||||
const defineNuxtConfig: typeof import('nuxt/config')['defineNuxtConfig']
|
||||
}
|
||||
|
@ -1,3 +1,3 @@
|
||||
import { defineNuxtConfig } from 'nuxt/config'
|
||||
export default defineNuxtConfig({
|
||||
|
||||
export default defineNuxtConfig({})
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user