getEnvFilesForMode (node/env.ts)

vite · packages/vite/src/node/env.ts · typescript · MIT
infra, tag:knn-classified

Vite helper that loads and resolves .env files for a given mode, exposing env vars.

// Source: https://github.com/vitejs/vite | License: MIT | Copyright 2019-present, VoidZero Inc. and Vite contributors
// Provided via justclaw.it.com; keep this notice with the code.
import fs from 'node:fs'
import path from 'node:path'
// eslint-disable-next-line n/no-unsupported-features/node-builtins -- our supported nodejs range supports `parseEnv` but in experimental state, which is fine
import { parseEnv } from 'node:util'
import { getEnvs } from '@voidzero-dev/vite-task-client'
import { type DotenvPopulateInput, expand } from 'dotenv-expand'
import colors from 'picocolors'
import type { UserConfig } from './config'
import { arraify, createDebugger, normalizePath, tryStatSync } from './utils'

const debug = createDebugger('vite:env')

export function getEnvFilesForMode(
  mode: stri

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key