vite-plugin-env.ts — astro Source File
Architecture documentation for vite-plugin-env.ts, a typescript file in the astro codebase. 10 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 241a5d79_df85_b217_dc9c_a74671cc544b["vite-plugin-env.ts"] ef8a1e3f_e350_75a6_b92d_62a8566d8db9["../core/errors/index.js"] 241a5d79_df85_b217_dc9c_a74671cc544b --> ef8a1e3f_e350_75a6_b92d_62a8566d8db9 f202f4fa_f9f9_9398_9510_7a42ce8ea007["../environments.js"] 241a5d79_df85_b217_dc9c_a74671cc544b --> f202f4fa_f9f9_9398_9510_7a42ce8ea007 e9b74c5a_8d34_34a7_e196_5e41b87214aa["../types/astro.js"] 241a5d79_df85_b217_dc9c_a74671cc544b --> e9b74c5a_8d34_34a7_e196_5e41b87214aa 63040f5c_bf79_3665_ce6d_7c06b710302a["./constants.js"] 241a5d79_df85_b217_dc9c_a74671cc544b --> 63040f5c_bf79_3665_ce6d_7c06b710302a 11b32933_a884_3b27_f001_e2d1b1259b07["./env-loader.js"] 241a5d79_df85_b217_dc9c_a74671cc544b --> 11b32933_a884_3b27_f001_e2d1b1259b07 3286ed3b_b4ab_78a3_0aff_00b1b2083234["./errors.js"] 241a5d79_df85_b217_dc9c_a74671cc544b --> 3286ed3b_b4ab_78a3_0aff_00b1b2083234 3a338670_ef65_2b57_cc61_29c1c222b236["../../env/schema.js"] 241a5d79_df85_b217_dc9c_a74671cc544b --> 3a338670_ef65_2b57_cc61_29c1c222b236 cc1161ce_d4d2_0bb4_bc6e_039c7a3d707c["./validators.js"] 241a5d79_df85_b217_dc9c_a74671cc544b --> cc1161ce_d4d2_0bb4_bc6e_039c7a3d707c e16a223b_37f3_6b25_1ee1_2b7bcb9d9415["node:fs"] 241a5d79_df85_b217_dc9c_a74671cc544b --> e16a223b_37f3_6b25_1ee1_2b7bcb9d9415 263e522e_1aa5_ebc3_e7d6_45ebc51671f7["vite"] 241a5d79_df85_b217_dc9c_a74671cc544b --> 263e522e_1aa5_ebc3_e7d6_45ebc51671f7 style 241a5d79_df85_b217_dc9c_a74671cc544b fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import { readFileSync } from 'node:fs';
import type { Plugin } from 'vite';
import { AstroError, AstroErrorData } from '../core/errors/index.js';
import { isAstroClientEnvironment } from '../environments.js';
import type { AstroSettings } from '../types/astro.js';
import {
CLIENT_VIRTUAL_MODULE_ID,
INTERNAL_VIRTUAL_MODULE_ID,
MODULE_TEMPLATE_URL,
RESOLVED_CLIENT_VIRTUAL_MODULE_ID,
RESOLVED_INTERNAL_VIRTUAL_MODULE_ID,
RESOLVED_SERVER_VIRTUAL_MODULE_ID,
SERVER_VIRTUAL_MODULE_ID,
} from './constants.js';
import type { EnvLoader } from './env-loader.js';
import { type InvalidVariable, invalidVariablesToError } from './errors.js';
import type { EnvSchema } from './schema.js';
import { getEnvFieldType, validateEnvVariable } from './validators.js';
interface AstroEnvPluginParams {
settings: AstroSettings;
sync: boolean;
envLoader: EnvLoader;
}
export function astroEnv({ settings, sync, envLoader }: AstroEnvPluginParams): Plugin {
const { schema, validateSecrets } = settings.config.env;
let isBuild: boolean;
let populated = false;
return {
name: 'astro-env-plugin',
enforce: 'pre',
config(_, { command }) {
isBuild = command === 'build';
},
buildStart() {
if (!isBuild || populated) {
return;
}
const loadedEnv = envLoader.get();
// During the build, we populate process.env so that secrets can work
for (const [key, value] of Object.entries(loadedEnv)) {
if (value !== undefined) {
process.env[key] = value;
}
}
populated = true;
},
resolveId: {
filter: {
id: new RegExp(
`^(${CLIENT_VIRTUAL_MODULE_ID}|${SERVER_VIRTUAL_MODULE_ID}|${INTERNAL_VIRTUAL_MODULE_ID})$`,
),
},
handler(id) {
if (id === CLIENT_VIRTUAL_MODULE_ID) {
// ... (154 more lines)
Domain
Subdomains
Dependencies
- ../../env/schema.js
- ../core/errors/index.js
- ../environments.js
- ../types/astro.js
- ./constants.js
- ./env-loader.js
- ./errors.js
- ./validators.js
- node:fs
- vite
Source
Frequently Asked Questions
What does vite-plugin-env.ts do?
vite-plugin-env.ts is a source file in the astro codebase, written in typescript. It belongs to the CoreAstro domain, RenderingEngine subdomain.
What functions are defined in vite-plugin-env.ts?
vite-plugin-env.ts defines 3 function(s): astroEnv, getTemplates, validatePublicVariables.
What does vite-plugin-env.ts depend on?
vite-plugin-env.ts imports 10 module(s): ../../env/schema.js, ../core/errors/index.js, ../environments.js, ../types/astro.js, ./constants.js, ./env-loader.js, ./errors.js, ./validators.js, and 2 more.
Where is vite-plugin-env.ts in the architecture?
vite-plugin-env.ts is located at packages/astro/src/env/vite-plugin-env.ts (domain: CoreAstro, subdomain: RenderingEngine, directory: packages/astro/src/env).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free