Skip to content
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
6 changes: 6 additions & 0 deletions .changeset/witty-lizards-jog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"website": minor
"@ladle/react": minor
---

Add option to set HMR host and port via the ladle config and update the docs with these options.
4 changes: 2 additions & 2 deletions packages/ladle/lib/cli/vite-dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ const bundler = async (config, configFolder) => {
});
const hmr = {
// needed for hmr to work over network aka WSL2
host: "localhost",
port: hmrPort,
host: config.hmrHost ?? "localhost",
port: config.hmrPort ?? hmrPort,
};
debug(`Port set to: ${port}`);
try {
Expand Down
2 changes: 2 additions & 0 deletions packages/ladle/lib/shared/default-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ export default {
noWatch: false,
port: 61000,
previewPort: 8080,
hmrHost: undefined,
hmrPort: undefined,
outDir: "build",
base: undefined,
hotkeys: {
Expand Down
2 changes: 2 additions & 0 deletions packages/ladle/lib/shared/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,8 @@ export type Config = {
port: number;
previewHost?: string;
previewPort: number;
hmrHost?: string;
hmrPort?: number;
outDir: string;
base?: string;
mode?: string;
Expand Down
22 changes: 22 additions & 0 deletions packages/website/docs/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,28 @@ export default {
};
```

### hmrHost

Specify the host for HMR.

```js
/** @type {import('@ladle/react').UserConfig} */
export default {
hmrHost: 0.0.0.0,
};
```

### hmrPort

Specify the port for HMR.

```js
/** @type {import('@ladle/react').UserConfig} */
export default {
hmrPort: 24678,
};
```

### outDir

Specify the output directory (relative to the project root).
Expand Down