Skip to content

Commit 55de74a

Browse files
authored
Add hmrHost and hmrPort to the ladle config (#558)
1 parent 0efc1c0 commit 55de74a

File tree

5 files changed

+34
-2
lines changed

5 files changed

+34
-2
lines changed

.changeset/witty-lizards-jog.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"website": minor
3+
"@ladle/react": minor
4+
---
5+
6+
Add option to set HMR host and port via the ladle config and update the docs with these options.

packages/ladle/lib/cli/vite-dev.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ const bundler = async (config, configFolder) => {
2929
});
3030
const hmr = {
3131
// needed for hmr to work over network aka WSL2
32-
host: "localhost",
33-
port: hmrPort,
32+
host: config.hmrHost ?? "localhost",
33+
port: config.hmrPort ?? hmrPort,
3434
};
3535
debug(`Port set to: ${port}`);
3636
try {

packages/ladle/lib/shared/default-config.js

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ export default {
1111
noWatch: false,
1212
port: 61000,
1313
previewPort: 8080,
14+
hmrHost: undefined,
15+
hmrPort: undefined,
1416
outDir: "build",
1517
base: undefined,
1618
hotkeys: {

packages/ladle/lib/shared/types.ts

+2
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,8 @@ export type Config = {
184184
port: number;
185185
previewHost?: string;
186186
previewPort: number;
187+
hmrHost?: string;
188+
hmrPort?: number;
187189
outDir: string;
188190
base?: string;
189191
mode?: string;

packages/website/docs/config.md

+22
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,28 @@ export default {
8888
};
8989
```
9090

91+
### hmrHost
92+
93+
Specify the host for HMR.
94+
95+
```js
96+
/** @type {import('@ladle/react').UserConfig} */
97+
export default {
98+
hmrHost: 0.0.0.0,
99+
};
100+
```
101+
102+
### hmrPort
103+
104+
Specify the port for HMR.
105+
106+
```js
107+
/** @type {import('@ladle/react').UserConfig} */
108+
export default {
109+
hmrPort: 24678,
110+
};
111+
```
112+
91113
### outDir
92114

93115
Specify the output directory (relative to the project root).

0 commit comments

Comments
 (0)