Skip to content
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

Feature - Add plugin host option #188

Merged
merged 5 commits into from
Oct 13, 2017
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
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ Then, sit back and pretend you're an astronaut.
- `-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 @@ -82,7 +82,8 @@ Then, sit back and pretend you're an astronaut.
#### 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 @@ -69,7 +71,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