Skip to content

Commit 606e60d

Browse files
Dunqingbluwy
andauthoredNov 30, 2022
feat!: support multiline values in env files (#10826)
Co-authored-by: bluwy <bjornlu.dev@gmail.com> close #10149
1 parent 1a54e58 commit 606e60d

File tree

3 files changed

+16
-19
lines changed

3 files changed

+16
-19
lines changed
 

‎packages/vite/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@
8989
"cross-spawn": "^7.0.3",
9090
"debug": "^4.3.4",
9191
"dep-types": "link:./src/types",
92-
"dotenv": "^14.3.2",
93-
"dotenv-expand": "^5.1.0",
92+
"dotenv": "^16.0.3",
93+
"dotenv-expand": "^9.0.0",
9494
"es-module-lexer": "^1.1.0",
9595
"estree-walker": "^3.0.1",
9696
"etag": "^1.8.1",

‎packages/vite/src/node/env.ts

+5-9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import fs from 'node:fs'
2-
import dotenv from 'dotenv'
3-
import dotenvExpand from 'dotenv-expand'
2+
import { parse } from 'dotenv'
3+
import { expand } from 'dotenv-expand'
44
import { arraify, lookupFile } from './utils'
55
import type { UserConfig } from './config'
66

@@ -31,23 +31,19 @@ export function loadEnv(
3131
rootDir: envDir
3232
})
3333
if (!path) return []
34-
return Object.entries(
35-
dotenv.parse(fs.readFileSync(path), {
36-
debug: process.env.DEBUG?.includes('vite:dotenv')
37-
})
38-
)
34+
return Object.entries(parse(fs.readFileSync(path)))
3935
})
4036
)
4137

4238
// let environment variables use each other
43-
const expandParsed = dotenvExpand({
39+
const expandParsed = expand({
4440
parsed: {
4541
...(process.env as any),
4642
...parsed
4743
},
4844
// prevent process.env mutation
4945
ignoreProcessEnv: true
50-
} as any).parsed!
46+
}).parsed!
5147

5248
Object.keys(parsed).forEach((key) => {
5349
parsed[key] = expandParsed[key]

‎pnpm-lock.yaml

+9-8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)