mirror of
https://github.com/nuxt/nuxt.git
synced 2025-01-31 07:40:33 +00:00
fix(kit): load .env
before loading nuxt.config
(#1086)
This commit is contained in:
parent
4f050e50bf
commit
d6ad4f3b16
@ -1,4 +1,4 @@
|
|||||||
import { existsSync, promises as fsp } from 'fs'
|
import { promises as fsp, existsSync } from 'fs'
|
||||||
import { resolve } from 'pathe'
|
import { resolve } from 'pathe'
|
||||||
import dotenv from 'dotenv'
|
import dotenv from 'dotenv'
|
||||||
import { LoadNuxtConfigOptions } from './load'
|
import { LoadNuxtConfigOptions } from './load'
|
||||||
|
@ -22,9 +22,11 @@ export interface LoadNuxtConfigOptions {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function loadNuxtConfig (opts: LoadNuxtConfigOptions): NuxtOptions {
|
export async function loadNuxtConfig (opts: LoadNuxtConfigOptions): Promise<NuxtOptions> {
|
||||||
const rootDir = resolve(process.cwd(), opts.rootDir || '.')
|
const rootDir = resolve(process.cwd(), opts.rootDir || '.')
|
||||||
|
|
||||||
|
await loadEnv(rootDir, opts.envConfig)
|
||||||
|
|
||||||
const nuxtConfigFile = tryResolveModule(resolve(rootDir, opts.configFile || 'nuxt.config'))
|
const nuxtConfigFile = tryResolveModule(resolve(rootDir, opts.configFile || 'nuxt.config'))
|
||||||
|
|
||||||
let nuxtConfig: any = {}
|
let nuxtConfig: any = {}
|
||||||
@ -50,8 +52,6 @@ export function loadNuxtConfig (opts: LoadNuxtConfigOptions): NuxtOptions {
|
|||||||
nuxtConfig.rootDir = rootDir
|
nuxtConfig.rootDir = rootDir
|
||||||
}
|
}
|
||||||
|
|
||||||
loadEnv(rootDir, opts.envConfig)
|
|
||||||
|
|
||||||
// Resolve and apply defaults
|
// Resolve and apply defaults
|
||||||
return applyDefaults(nuxtConfigSchema, nuxtConfig) as NuxtOptions
|
return applyDefaults(nuxtConfigSchema, nuxtConfig) as NuxtOptions
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,7 @@ async function initNuxt (nuxt: Nuxt) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function loadNuxt (opts: LoadNuxtOptions): Promise<Nuxt> {
|
export async function loadNuxt (opts: LoadNuxtOptions): Promise<Nuxt> {
|
||||||
const options = loadNuxtConfig(opts)
|
const options = await loadNuxtConfig(opts)
|
||||||
|
|
||||||
// Temp
|
// Temp
|
||||||
options.appDir = options.alias['#app'] = resolve(distDir, 'app')
|
options.appDir = options.alias['#app'] = resolve(distDir, 'app')
|
||||||
|
Loading…
Reference in New Issue
Block a user