vite · Vite Docs
Env Variables and Modes | Vite (main branch)
Explains how to use environment variables with the VITE_ prefix and how to manage different application modes like development and production.
Derived skill
Files assembled from official documentation
Viewing SKILL.md
Env Variables and Modes | Vite (main branch)
Explains how to use environment variables with the VITE_ prefix and how to manage different application modes like development and production.
When To Use
Use when you need to expose environment variables to your client-side code or configure application behavior based on the current build mode.
Reference Files
| File | Contains | Use For |
|---|---|---|
SKILL.md | Entry point: scope, routing table, and workflow. | Start here. |
docs/main-vite-env-variables-and-modes-branch-workflow-guide.md | A guide explaining Vite's built-in constants, environment variable handling via .env files, and TypeScript IntelliSense support. | Questions about a guide explaining Vite's built-in constants, environment variable handling via .env files, and TypeScript IntelliSen... |
examples/main-vite-env-variables-and-modes-branch-vite-env-variables-and-modes-us.text | A text example demonstrating how to access environment variables and mode flags using import.meta.env in a Vite project. | Exact payloads, commands, or snippets shown in A text example demonstrating how to access environment variables and mode flags using import.meta.env in a Vite project. |
examples/main-vite-env-variables-and-modes-branch-vite-env-variables-and-modes.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/main-vite-env-variables-and-modes-branch-vite-env-variables-and-modes-us-2.text | A demonstration of accessing environment variables via import.meta.env and the behavior of prefixed versus non-prefixed variables in Vite. | Exact payloads, commands, or snippets shown in A demonstration of accessing environment variables via import.meta.env and the behavior of prefixed versus non-prefix... |
examples/main-vite-env-variables-and-modes-branch-vite-env-variables-and-modes-co.text | A text file demonstrating the hierarchy and loading rules for different .env file variations in Vite. | Exact payloads, commands, or snippets shown in A text file demonstrating the hierarchy and loading rules for different .env file variations in Vite. |
examples/main-vite-env-variables-and-modes-branch-vite-env-variables-and-modes-2.text | A text file demonstrating how to define environment variables with special characters and comments for Vite. | Exact payloads, commands, or snippets shown in A text file demonstrating how to define environment variables with special characters and comments for Vite. |
examples/main-vite-env-variables-and-modes-branch-vite-env-variables-and-modes-3.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/main-vite-env-variables-and-modes-branch-vite-env-variables-and-modes-im.text | A TypeScript interface definition for strict typing of ImportMetaEnv to allow custom environment variable keys in Vite. | Exact payloads, commands, or snippets shown in A TypeScript interface definition for strict typing of ImportMetaEnv to allow custom environment variable keys in Vite. |
examples/main-vite-env-variables-and-modes-branch-vite-env-variables-and-modes-co-2.text | A configuration example demonstrating how to define and use environment variables and modes within a Vite project. | Exact payloads, commands, or snippets shown in A configuration example demonstrating how to define and use environment variables and modes within a Vite project. |
examples/main-vite-env-variables-and-modes-branch-vite-env-variables-and-modes-us-3.text | A text example demonstrating how to use environment variables and mode placeholders within a Vite application template. | Exact payloads, commands, or snippets shown in A text example demonstrating how to use environment variables and mode placeholders within a Vite application template. |
examples/main-vite-env-variables-and-modes-branch-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/main-vite-env-variables-and-modes-branch-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/main-vite-env-variables-and-modes-branch-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/main-vite-env-variables-and-modes-branch-vite-env-variables-and-modes-no.text | A text example demonstrating the usage of the NODE_ENV=development environment variable within a Vite project. | Exact payloads, commands, or snippets shown in A text example demonstrating the usage 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://main.vite.dev/guide/env-and-mode