Skip to content

Latest commit

 

History

History
51 lines (34 loc) · 1.16 KB

File metadata and controls

51 lines (34 loc) · 1.16 KB

Vite Plugin GitHub Codespace HMR

Vite plugin to set the correct HMR client hostname in GitHub Codespaces when the HMR client port differs from the server port.

Note

While this plugin sets the correct client hostname in Vite's client script, you may need to open the address of the forwaded HMR port in your browser once for it to work. When the server and HMR address are the same, this step is unnecessary because you are likely opening the address to view your app.

Reference: vitejs/vite#8666 (comment)

Installation

npm install @edivados/vite-plugin-github-codespace-hmr

Usage

import { defineConfig } from "vite";
import codespaceHMR from "@edivados/vite-plugin-github-codespace-hmr";

export default defineConfig({
   server: {
    hmr: {
      port: 4040
    }
  },
  plugins: [codespaceHMR()]
});

Options

options

  • Type: Object
  • Default: {}

options.open

  • Type: boolean
  • Default: false

Indicates whether the plugin should open the HMR address.

options.openTimeout

  • Type: number
  • Default: 2000

The timeout duration (in milliseconds) before the HMR address is opened.