vite · Vite Docs
Vite Vite Env Variables and Modes
Explains how to use environment variables via import.meta.env and how to manage different build modes in Vite.
Derived skill
Files assembled from official documentation
Viewing SKILL.md
Vite Vite Env Variables and Modes
Explains how to use environment variables via import.meta.env and how to manage different build modes in Vite.
When To Use
Use when you need to access environment variables in client-side code or configure different application behaviors based on development, production, or custom modes.
Reference Files
| File | Contains | Use For |
|---|---|---|
SKILL.md | Entry point: scope, routing table, and workflow. | Start here. |
docs/vite-env-variables-and-modes-workflow-guide.md | A guide explaining Vite's built-in constants, environment variables, .env file usage, and TypeScript IntelliSense configuration. | Questions about a guide explaining Vite's built-in constants, environment variables, .env file usage, and TypeScript IntelliSense con... |
examples/vite-env-variables-and-modes-usage.text | A text example demonstrating how to access Vite environment variables and mode flags using import.meta.env. | Exact payloads, commands, or snippets shown in A text example demonstrating how to access Vite environment variables and mode flags using import.meta.env. |
examples/vite-env-variables-and-modes.text | An example of environment variable declarations using the VITE_ prefix for use within a Vite project. | Exact payloads, commands, or snippets shown in An example of environment variable declarations using the VITE prefix for use within a Vite project. |
examples/vite-env-variables-and-modes-access.text | A text example demonstrating how to access environment variables using import.meta.env in a Vite project. | Exact payloads, commands, or snippets shown in A text example demonstrating how to access environment variables using import.meta.env in a Vite project. |
examples/vite-env-variables-and-modes-vite-env-variable-loading-priority-modes.text | A text file demonstrating the hierarchy and loading rules for .env files across different modes and local overrides. | Exact payloads, commands, or snippets shown in A text file demonstrating the hierarchy and loading rules for .env files across different modes and local overrides. |
examples/vite-env-variables-and-modes-dotenv-syntax-examples.text | A text file demonstrating how to use special characters and variable expansion within Vite environment variable definitions. | Exact payloads, commands, or snippets shown in A text file demonstrating how to use special characters and variable expansion within Vite environment variable defin... |
examples/vite-env-variables-and-modes-2.text | An example demonstrating the syntax for defining and interpolating environment variables in a Vite configuration. | Exact payloads, commands, or snippets shown in An example demonstrating the syntax for defining and interpolating environment variables in a Vite configuration. |
examples/vite-env-variables-and-modes-typescript-interface-definition.text | A TypeScript interface definition for strict typing of ImportMetaEnv and ImportMeta in a Vite project. | Exact payloads, commands, or snippets shown in A TypeScript interface definition for strict typing of ImportMetaEnv and ImportMeta in a Vite project. |
examples/vite-env-variables-and-modes-configuration.text | A text configuration demonstrating how Vite handles environment variables and mode-specific settings. | Exact payloads, commands, or snippets shown in A text configuration demonstrating how Vite handles environment variables and mode-specific settings. |
examples/vite-env-variables-and-modes-3.text | A text example demonstrating the use of Vite environment variables and mode interpolation within a template string. | Exact payloads, commands, or snippets shown in A text example demonstrating the use of Vite environment variables and mode interpolation within a template string. |
examples/vite-env-variables-and-modes-4.text | An example demonstrating the syntax for defining environment variables using the VITE_ prefix. | Exact payloads, commands, or snippets shown in An example demonstrating the syntax for defining environment variables using the VITE prefix. |
examples/vite-env-variables-and-modes-vite-build-mode-staging-command.text | A command line instruction demonstrating how to use the vite build command with the staging mode flag. | Exact payloads, commands, or snippets shown in A command line instruction demonstrating how to use the vite build command with the staging mode flag. |
examples/vite-env-variables-and-modes-5.text | An example demonstrating the syntax for defining environment variables using the VITE_ prefix for different modes. | Exact payloads, commands, or snippets shown in An example demonstrating the syntax for defining environment variables using the VITE prefix for different modes. |
examples/vite-env-variables-and-modes-node-env-development.text | An example demonstrating the use of the NODE_ENV=development environment variable within a Vite project. | Exact payloads, commands, or snippets shown in An example demonstrating the use of the NODEENV=development environment variable within a Vite project. |
What This Skill Covers
- Are you an LLM? You can read better optimized documentation at /guide/env-and-mode.md for this page in Markdown format
- Main sections:
Built-in Constants ,Env Variables ,.env Files ,IntelliSense for TypeScript ,HTML Constant Replacement .
Workflow
- Open the most relevant file under
docs/for the exact documented workflow and wording. - Open
schemas/files for exact structured contracts. - Open
examples/files for concrete requests, commands, snippets, and manifests. - Do not add behavior or configuration that is not present in the attached source files.
Canonical source: https://vite.dev/guide/env-and-mode