Home / Function/ hotEventsPlugin() — vite Function Reference

hotEventsPlugin() — vite Function Reference

Architecture documentation for the hotEventsPlugin() function in vite.config.ts from the vite codebase.

Entity Profile

Dependency Diagram

graph TD
  457e901a_ebf9_40cc_5d67_22d1ece1c784["hotEventsPlugin()"]
  1881247f_497c_87d7_8eb6_75c8f50658ae["vite.config.ts"]
  457e901a_ebf9_40cc_5d67_22d1ece1c784 -->|defined in| 1881247f_497c_87d7_8eb6_75c8f50658ae
  style 457e901a_ebf9_40cc_5d67_22d1ece1c784 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

playground/hmr/vite.config.ts lines 123–143

function hotEventsPlugin(): Plugin {
  return {
    name: 'hot-events',
    configureServer(server) {
      let connectCount = 0
      let disconnectCount = 0
      const clientEnv = server.environments.client
      clientEnv.hot.on('vite:client:connect', () => connectCount++)
      clientEnv.hot.on('vite:client:disconnect', () => disconnectCount++)

      server.middlewares.use((req, res, next) => {
        if (req.url === '/hot-events-counts') {
          res.setHeader('Content-Type', 'application/json')
          res.end(JSON.stringify({ connectCount, disconnectCount }))
          return
        }
        next()
      })
    },
  }
}

Domain

Subdomains

Frequently Asked Questions

What does hotEventsPlugin() do?
hotEventsPlugin() is a function in the vite codebase, defined in playground/hmr/vite.config.ts.
Where is hotEventsPlugin() defined?
hotEventsPlugin() is defined in playground/hmr/vite.config.ts at line 123.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free