Skip to content

Commit

Permalink
feat: support dotenv expand
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Jun 19, 2020
1 parent 51e9c83 commit 7a4606d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
"clean-css": "^4.2.3",
"debug": "^4.1.1",
"dotenv": "^8.2.0",
"dotenv-expand": "^5.1.0",
"es-module-lexer": "^0.3.18",
"esbuild": "^0.4.1",
"etag": "^1.8.1",
Expand Down
2 changes: 2 additions & 0 deletions src/node/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import path from 'path'
import fs from 'fs-extra'
import chalk from 'chalk'
import dotenv, { DotenvParseOutput } from 'dotenv'
import dotenvExpand from 'dotenv-expand'
import { Options as RollupPluginVueOptions } from 'rollup-plugin-vue'
import { CompilerOptions, SFCStyleCompileOptions } from '@vue/compiler-sfc'
import Rollup, {
Expand Down Expand Up @@ -465,6 +466,7 @@ function loadEnv(mode: string, root: string): Record<string, string> {
if (result.error) {
throw result.error
}
dotenvExpand(result)
for (const key in result.parsed) {
// only keys that start with VITE_ are exposed.
if (key.startsWith(`VITE_`)) {
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2286,6 +2286,11 @@ dot-prop@^3.0.0:
dependencies:
is-obj "^1.0.0"

dotenv-expand@^5.1.0:
version "5.1.0"
resolved "https://registry.yarnpkg.com/dotenv-expand/-/dotenv-expand-5.1.0.tgz#3fbaf020bfd794884072ea26b1e9791d45a629f0"
integrity sha512-YXQl1DSa4/PQyRfgrv6aoNjhasp/p4qs9FjJ4q4cQk+8m4r6k4ZSiEyytKG8f8W9gi8WsQtIObNmKd+tMzNTmA==

dotenv@^8.2.0:
version "8.2.0"
resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-8.2.0.tgz#97e619259ada750eea3e4ea3e26bceea5424b16a"
Expand Down

0 comments on commit 7a4606d

Please sign in to comment.