Skip to content

Commit

Permalink
Feature - Add plugin host option (#188)
Browse files Browse the repository at this point in the history
* Add support to change the host in the plugin options

* Add the host option to the documentation and clarify in the docs what act as server and what act as client

* Fix the double quote lint error
  • Loading branch information
gartz authored and Carlos Paelinck committed Oct 13, 2017
1 parent 3f558c3 commit 2f24fe9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ Webpack Dashboard works in Terminal, iTerm 2, and Hyper. For mouse events, like
- `-c, --color [color]` - Custom ANSI color for your dashboard
- `-m, --minimal` - Runs the dashboard in minimal mode
- `-t, --title [title]` - Set title of terminal window
- `-p, --port [port]` - Custom port for socket communication
- `-p, --port [port]` - Custom port for socket communication server

##### Arguments

Expand All @@ -94,7 +94,8 @@ Webpack Dashboard works in Terminal, iTerm 2, and Hyper. For mouse events, like
#### Webpack plugin
#### Options

- `port` - Custom port for socket communication
- `host` - Custom host for connection the socket client
- `port` - Custom port for connecting the socket client
- `root` - Custom full path to project root (where `package.json` + `node_modules` are if not in `process.cwd()`)
- `handler` - Plugin handler method, i.e. `dashboard.setData`

Expand Down
4 changes: 3 additions & 1 deletion plugin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const InspectpackDaemon = require("inspectpack").daemon;
const serializeError = require("../utils/error-serialization").serializeError;

const DEFAULT_PORT = 9838;
const DEFAULT_HOST = "127.0.0.1";
const ONE_SECOND = 1000;
const INSPECTPACK_PROBLEM_ACTIONS = ["versions", "duplicates"];
const INSPECTPACK_PROBLEM_TYPE = "problems";
Expand Down Expand Up @@ -40,6 +41,7 @@ class DashboardPlugin {
this.handler = options;
} else {
options = options || {};
this.host = options.host || DEFAULT_HOST;
this.port = options.port || DEFAULT_PORT;
this.root = options.root;
this.handler = options.handler || null;
Expand Down Expand Up @@ -75,7 +77,7 @@ class DashboardPlugin {
if (!handler) {
handler = noop;
const port = this.port;
const host = "127.0.0.1";
const host = this.host;
this.socket = new SocketIOClient(`http://${host}:${port}`);
this.socket.on("connect", () => {
handler = this.socket.emit.bind(this.socket, "message");
Expand Down

0 comments on commit 2f24fe9

Please sign in to comment.