mirror of
https://github.com/vitejs/vite.git
synced 2024-11-21 22:59:10 +00:00
feat!: support multiline values in env files (#10826)
Co-authored-by: bluwy <bjornlu.dev@gmail.com> close https://github.com/vitejs/vite/issues/10149
This commit is contained in:
parent
1a54e58fbd
commit
606e60d591
@ -89,8 +89,8 @@
|
||||
"cross-spawn": "^7.0.3",
|
||||
"debug": "^4.3.4",
|
||||
"dep-types": "link:./src/types",
|
||||
"dotenv": "^14.3.2",
|
||||
"dotenv-expand": "^5.1.0",
|
||||
"dotenv": "^16.0.3",
|
||||
"dotenv-expand": "^9.0.0",
|
||||
"es-module-lexer": "^1.1.0",
|
||||
"estree-walker": "^3.0.1",
|
||||
"etag": "^1.8.1",
|
||||
|
@ -1,6 +1,6 @@
|
||||
import fs from 'node:fs'
|
||||
import dotenv from 'dotenv'
|
||||
import dotenvExpand from 'dotenv-expand'
|
||||
import { parse } from 'dotenv'
|
||||
import { expand } from 'dotenv-expand'
|
||||
import { arraify, lookupFile } from './utils'
|
||||
import type { UserConfig } from './config'
|
||||
|
||||
@ -31,23 +31,19 @@ export function loadEnv(
|
||||
rootDir: envDir
|
||||
})
|
||||
if (!path) return []
|
||||
return Object.entries(
|
||||
dotenv.parse(fs.readFileSync(path), {
|
||||
debug: process.env.DEBUG?.includes('vite:dotenv')
|
||||
})
|
||||
)
|
||||
return Object.entries(parse(fs.readFileSync(path)))
|
||||
})
|
||||
)
|
||||
|
||||
// let environment variables use each other
|
||||
const expandParsed = dotenvExpand({
|
||||
const expandParsed = expand({
|
||||
parsed: {
|
||||
...(process.env as any),
|
||||
...parsed
|
||||
},
|
||||
// prevent process.env mutation
|
||||
ignoreProcessEnv: true
|
||||
} as any).parsed!
|
||||
}).parsed!
|
||||
|
||||
Object.keys(parsed).forEach((key) => {
|
||||
parsed[key] = expandParsed[key]
|
||||
|
@ -235,8 +235,8 @@ importers:
|
||||
cross-spawn: ^7.0.3
|
||||
debug: ^4.3.4
|
||||
dep-types: link:./src/types
|
||||
dotenv: ^14.3.2
|
||||
dotenv-expand: ^5.1.0
|
||||
dotenv: ^16.0.3
|
||||
dotenv-expand: ^9.0.0
|
||||
es-module-lexer: ^1.1.0
|
||||
esbuild: ^0.15.9
|
||||
estree-walker: ^3.0.1
|
||||
@ -302,8 +302,8 @@ importers:
|
||||
cross-spawn: 7.0.3
|
||||
debug: 4.3.4
|
||||
dep-types: link:src/types
|
||||
dotenv: 14.3.2
|
||||
dotenv-expand: 5.1.0
|
||||
dotenv: 16.0.3
|
||||
dotenv-expand: 9.0.0
|
||||
es-module-lexer: 1.1.0
|
||||
estree-walker: 3.0.1
|
||||
etag: 1.8.1
|
||||
@ -4097,12 +4097,13 @@ packages:
|
||||
is-obj: 2.0.0
|
||||
dev: true
|
||||
|
||||
/dotenv-expand/5.1.0:
|
||||
resolution: {integrity: sha512-YXQl1DSa4/PQyRfgrv6aoNjhasp/p4qs9FjJ4q4cQk+8m4r6k4ZSiEyytKG8f8W9gi8WsQtIObNmKd+tMzNTmA==}
|
||||
/dotenv-expand/9.0.0:
|
||||
resolution: {integrity: sha512-uW8Hrhp5ammm9x7kBLR6jDfujgaDarNA02tprvZdyrJ7MpdzD1KyrIHG4l+YoC2fJ2UcdFdNWNWIjt+sexBHJw==}
|
||||
engines: {node: '>=12'}
|
||||
dev: true
|
||||
|
||||
/dotenv/14.3.2:
|
||||
resolution: {integrity: sha512-vwEppIphpFdvaMCaHfCEv9IgwcxMljMw2TnAQBB4VWPvzXQLTb82jwmdOKzlEVUL3gNFT4l4TPKO+Bn+sqcrVQ==}
|
||||
/dotenv/16.0.3:
|
||||
resolution: {integrity: sha512-7GO6HghkA5fYG9TYnNxi14/7K9f5occMlp3zXAuSxn7CKCxt9xbNWG7yF8hTCSUchlfWSe3uLmlPfigevRItzQ==}
|
||||
engines: {node: '>=12'}
|
||||
dev: true
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user