fix(kit): dotenv esm compactiblity (#799)

Co-authored-by: pooya parsa <pyapar@gmail.com>
This commit is contained in:
Anthony Fu 2021-10-13 00:21:01 +08:00 committed by GitHub
parent 926062db3d
commit 6e52775bf9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,6 +1,6 @@
import { existsSync, promises as fsp } from 'fs' import { existsSync, promises as fsp } from 'fs'
import { resolve } from 'pathe' import { resolve } from 'pathe'
import { parse as parseDotEnv } from 'dotenv' import dotenv from 'dotenv'
import { LoadNuxtConfigOptions } from './load' import { LoadNuxtConfigOptions } from './load'
export interface LoadDotEnvOptions { export interface LoadDotEnvOptions {
@ -62,7 +62,7 @@ export async function loadDotenv (opts: LoadDotEnvOptions) {
const dotenvFile = resolve(opts.rootDir, opts.dotenvFile) const dotenvFile = resolve(opts.rootDir, opts.dotenvFile)
if (existsSync(dotenvFile)) { if (existsSync(dotenvFile)) {
const parsed = parseDotEnv(await fsp.readFile(dotenvFile, 'utf-8')) const parsed = dotenv.parse(await fsp.readFile(dotenvFile, 'utf-8'))
Object.assign(env, parsed) Object.assign(env, parsed)
} }