PART 04
Hooks deep dive
Universal / Vite-only / Rolldown-extension hooks — the full picture and timing differences.
- 4.1Hooks PanoramaA complete overview of all Vite/Rolldown hooks. Where are the boundaries between universal build hooks, Vite-specific hooks, and Rolldown extension hooks? What is the execution order?
- 4.2Universal Build Hooks (Part 1): options / buildStart / resolveId / loadA deep dive into the first four core build hooks — from reading configuration and initializing the build, to resolving paths and loading modules. Parameters, return values, and typical usage for each hook.
- 4.3Universal Build Hooks (Part 2): transform / buildEnd / generateBundle / writeBundleThe transform pipeline at the heart of the plugin system, plus four hooks that run during the build finalization phase. Understand how the transform chain passes code along, and how to perform last-mile processing after output is generated.
- 4.4Vite-Specific Hooks (Part 1): config / configResolved / configureServerThe server-side hooks Vite adds on top of Rollup — how to modify configuration at runtime, access the dev server instance, and add custom middleware.
- 4.5Vite-Specific Hooks (Part 2): transformIndexHtml / handleHotUpdateTwo of Vite's most distinctive hooks — transformIndexHtml for direct HTML template manipulation, and handleHotUpdate for fine-grained HMR control.
- 4.6Environment-Related HooksThe `buildApp` hook introduced in Vite 7 and the multi-environment awareness brought by the Environment API — how to customize build behavior per environment.
- 4.7Hook Behavior Differences Between Rolldown and RollupFrom Vite 7 (Rollup) to Vite 8 (Rolldown) — which hooks behave identically? Which have subtle differences? How do you write plugins that work well with both?
- 4.8Project 2: Markdown LoaderUse load + transform to turn .md files into hot-reloadable React components. Build vite-plugin-md from scratch and understand the full transform pipeline.
- 4.9Project 3: i18n Auto-injectionCombine transformIndexHtml + resolveId + load to build an i18n injection plugin that requires no manual imports, with automatic HMR when language packs change.