vitePluginEnvironment() — astro Function Reference
Architecture documentation for the vitePluginEnvironment() function in index.ts from the astro codebase.
Entity Profile
Dependency Diagram
graph TD 32edd508_1b37_e75c_1c15_fabce3fe5447["vitePluginEnvironment()"] 1ab33465_d174_4d12_56c8_8d8e7d679cb7["index.ts"] 32edd508_1b37_e75c_1c15_fabce3fe5447 -->|defined in| 1ab33465_d174_4d12_56c8_8d8e7d679cb7 style 32edd508_1b37_e75c_1c15_fabce3fe5447 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/astro/src/vite-plugin-environment/index.ts lines 43–104
export function vitePluginEnvironment({
command,
settings,
astroPkgsConfig,
}: Payload): vite.Plugin {
const srcDirPattern = convertPathToPattern(fileURLToPath(settings.config.srcDir));
return {
name: 'astro:environment',
configEnvironment(environmentName, _options): EnvironmentOptions {
const finalEnvironmentOptions: EnvironmentOptions = {
optimizeDeps: {
include: [],
exclude: [],
},
resolve: {
// Astro imports in third-party packages should use the same version as root
dedupe: ['astro'],
},
};
if (
environmentName === ASTRO_VITE_ENVIRONMENT_NAMES.ssr ||
environmentName === ASTRO_VITE_ENVIRONMENT_NAMES.astro ||
environmentName === ASTRO_VITE_ENVIRONMENT_NAMES.prerender ||
environmentName === ASTRO_VITE_ENVIRONMENT_NAMES.client
) {
if (_options.resolve?.noExternal !== true) {
finalEnvironmentOptions.resolve!.noExternal = [
...ALWAYS_NOEXTERNAL,
...astroPkgsConfig.ssr.noExternal,
];
finalEnvironmentOptions.resolve!.external = [
...(command === 'dev' ? ONLY_DEV_EXTERNAL : []),
...astroPkgsConfig.ssr.external,
];
}
if (_options.optimizeDeps?.noDiscovery === false) {
finalEnvironmentOptions.optimizeDeps = {
entries: [`${srcDirPattern}**/*.{jsx,tsx,vue,svelte,html,astro}`],
include: [],
exclude: ['node-fetch'],
};
}
}
if (environmentName === ASTRO_VITE_ENVIRONMENT_NAMES.client) {
finalEnvironmentOptions.optimizeDeps = {
include: [
// For the dev toolbar
'astro > html-escaper',
],
exclude: ['astro:*', 'virtual:astro:*'],
// Astro files can't be rendered on the client
entries: [`${srcDirPattern}**/*.{jsx,tsx,vue,svelte,html}`],
};
}
return finalEnvironmentOptions;
},
};
}
Domain
Subdomains
Source
Frequently Asked Questions
What does vitePluginEnvironment() do?
vitePluginEnvironment() is a function in the astro codebase, defined in packages/astro/src/vite-plugin-environment/index.ts.
Where is vitePluginEnvironment() defined?
vitePluginEnvironment() is defined in packages/astro/src/vite-plugin-environment/index.ts at line 43.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free