Skip to content

docs: add vite-hmr guide #796

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions guides/troubleshooting/vite-hmr.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
title: Vite and HMR
description: Learn how to resolve issues with HMR when using Vite.
---

When using Vite and accessing your app via
[dev URLs](../../workspaces/devurls.md), you may encounter issues with hot
module reloading (HMR) not working.

## Why this happens

Vite runs a WebSocket for hot module reloading (HMR) and assumes the client will
listen on a specific port. If this isn't the case, Vite HMR and the client never
connect.

## How to fix

Edit your `vite.config.js` file and add the following information to provide the
appropriate port number:

```js
server: {
hmr: {
clientPort: 443
},
},
```

If this doesn't resolve the issue, please
[contact us](https://coder.com/contact) for further support.
3 changes: 3 additions & 0 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,9 @@
},
{
"path": "./guides/troubleshooting/502error.md"
},
{
"path": "./guides/troubleshooting/vite-hmr.md"
}
]
}
Expand Down