Prompt Buddy logoPrompt Buddy

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.

Import to Prompt Buddy

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

FileContainsUse For
SKILL.mdEntry point: scope, routing table, and workflow.Start here.
docs/main-vite-environment-api-for-plugins-branch-workflow-guide.mdA 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.textA 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.textA 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.textA 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.textThe 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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

  1. Open the most relevant file under docs/ for the exact documented workflow and wording.
  2. Open schemas/ files for exact structured contracts.
  3. Open examples/ files for concrete requests, commands, snippets, and manifests.
  4. 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