vite · Vite Docs
Environment API for Plugins | Vite (main branch)
Explains how to use the Environment API within Vite plugins to access environment-specific configurations and hooks.
Derived skill
Files assembled from official documentation
Viewing SKILL.md
Environment API for Plugins | Vite (main branch)
Explains how to use the Environment API within Vite plugins to access environment-specific configurations and hooks.
When To Use
Use when developing Vite plugins that need to perform different actions or access different configurations based on the specific environment being processed.
Reference Files
| File | Contains | Use For |
|---|---|---|
SKILL.md | Entry point: scope, routing table, and workflow. | Start here. |
docs/main-vite-environment-api-for-plugins-branch-workflow-guide.md | A guide explaining how to access, register, and configure environments using the Vite plugin API and hooks. | Questions about a guide explaining how to access, register, and configure environments using the Vite plugin API and hooks. |
examples/main-vite-environment-api-for-plugins-branch-vite-environment-api-plugin.text | A code example demonstrating how to access the environment configuration object within a plugin's transform hook. | Exact payloads, commands, or snippets shown in A code example demonstrating how to access the environment configuration object within a plugin's transform hook. |
examples/main-vite-environment-api-for-plugins-branch-vite-environment-api-plugin-2.text | A code example demonstrating how to use the Environment API within a Vite plugin configuration to define custom environments and resolve conditions. | Exact payloads, commands, or snippets shown in A code example demonstrating how to use the Environment API within a Vite plugin configuration to define custom envir... |
examples/main-vite-environment-api-for-plugins-branch-vite-environment-api-plugin-3.text | A code example demonstrating how to use the configEnvironment function within a Vite plugin to configure environment-specific options. | Exact payloads, commands, or snippets shown in A code example demonstrating how to use the configEnvironment function within a Vite plugin to configure environment-... |
examples/main-vite-environment-api-for-plugins-branch-vite-environment-api-hot-up.text | The TypeScript interface definition for HotUpdateOptions within the Vite Environment API. | Exact payloads, commands, or snippets shown in The TypeScript interface definition for HotUpdateOptions within the Vite Environment API. |
examples/main-vite-environment-api-for-plugins-branch-vite-environment-api-plugin-4.text | A JavaScript code example demonstrating how to use the environment API within a Vite plugin to handle hot module replacement updates. | Exact payloads, commands, or snippets shown in A JavaScript code example demonstrating how to use the environment API within a Vite plugin to handle hot module repl... |
examples/main-vite-environment-api-for-plugins-branch-vite-environment-api-plugin-5.text | A code example demonstrating how to use the environment API within a Vite plugin to intercept and send custom hot update events. | Exact payloads, commands, or snippets shown in A code example demonstrating how to use the environment API within a Vite plugin to intercept and send custom hot upd... |
examples/main-vite-environment-api-for-plugins-branch-vite-environment-api-plugin-6.text | A text example demonstrating the use of the Vite Environment API to handle custom hot updates within a plugin using import.meta.hot. | Exact payloads, commands, or snippets shown in A text example demonstrating the use of the Vite Environment API to handle custom hot updates within a plugin using i... |
examples/main-vite-environment-api-for-plugins-branch-vite-environment-api-plugin-7.text | A JavaScript plugin implementation demonstrating how to track and count transformed modules per environment using the Vite Environment API. | Exact payloads, commands, or snippets shown in A JavaScript plugin implementation demonstrating how to track and count transformed modules per environment using the... |
examples/main-vite-environment-api-for-plugins-branch-vite-environment-api-plugin-8.text | A JavaScript code example demonstrating how to use the Vite Environment API within a plugin to manage per-environment state using WeakMap and the applyToEnvironment hook. | Exact payloads, commands, or snippets shown in A JavaScript code example demonstrating how to use the Vite Environment API within a plugin to manage per-environment... |
examples/main-vite-environment-api-for-plugins-branch-vite-environment-api-plugin-9.text | A code example demonstrating how to use the applyToEnvironment function within a Vite plugin to return environment-specific configurations. | Exact payloads, commands, or snippets shown in A code example demonstrating how to use the applyToEnvironment function within a Vite plugin to return environment-sp... |
examples/main-vite-environment-api-for-plugins-branch-vite-environment-api-plugin-10.text | A code example demonstrating how to use the Vite Environment API to create a plugin that provides non-shareable configurations for specific environments. | Exact payloads, commands, or snippets shown in A code example demonstrating how to use the Vite Environment API to create a plugin that provides non-shareable confi... |
examples/main-vite-environment-api-for-plugins-branch-vite-environment-api-plugin-11.text | A code example demonstrating how to use the Vite Environment API within a plugin's configureServer hook to listen for and send hot events. | Exact payloads, commands, or snippets shown in A code example demonstrating how to use the Vite Environment API within a plugin's configureServer hook to listen for... |
examples/main-vite-environment-api-for-plugins-branch-vite-environment-api-plugin-12.text | A JavaScript code example demonstrating how to use the Environment API to share state among all environments in a Vite plugin. | Exact payloads, commands, or snippets shown in A JavaScript code example demonstrating how to use the Environment API to share state among all environments in a Vit... |
What This Skill Covers
- Are you an LLM? You can read better optimized documentation at /guide/api-environment-plugins.md for this page in Markdown format
- Main sections:
Accessing the Current Environment in Hooks ,Registering New Environments Using Hooks ,Configuring Environment Using Hooks ,The hotUpdate Hook ,Per-environment State in Plugins .
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/api-environment-plugins